From: bep Date: Fri, 1 May 2015 10:29:10 +0000 (+0200) Subject: absurl: export a base url var for testing X-Git-Tag: v0.14~97 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=be049ff9;p=brevno-suite%2Fhugo absurl: export a base url var for testing --- diff --git a/transform/absurl.go b/transform/absurl.go index 89727a70..75dbe4db 100644 --- a/transform/absurl.go +++ b/transform/absurl.go @@ -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) }) }