mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
absurl: export a base url var for testing
This commit is contained in:
parent
be9df84772
commit
be049ff96a
1 changed files with 12 additions and 1 deletions
|
@ -5,6 +5,9 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// to be used in tests; the live site will get its value from Viper.
|
||||
var AbsBaseUrl string
|
||||
|
||||
var absURLInit sync.Once
|
||||
var ar *absURLReplacer
|
||||
|
||||
|
@ -42,6 +45,14 @@ func absURLInXMLFromReplacer(ar *absURLReplacer) (trs []link, err error) {
|
|||
|
||||
func initAbsURLReplacer() {
|
||||
absURLInit.Do(func() {
|
||||
ar = newAbsURLReplacer(viper.GetString("BaseURL"))
|
||||
var url string
|
||||
|
||||
if AbsBaseUrl != "" {
|
||||
url = AbsBaseUrl
|
||||
} else {
|
||||
url = viper.GetString("BaseURL")
|
||||
}
|
||||
|
||||
ar = newAbsURLReplacer(url)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue