absurl: export a base url var for testing

This commit is contained in:
bep 2015-05-01 12:29:10 +02:00
parent be9df84772
commit be049ff96a

View file

@ -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)
})
}