From be049ff96ad5c5af1192316b43a2e9577ef0b065 Mon Sep 17 00:00:00 2001 From: bep Date: Fri, 1 May 2015 12:29:10 +0200 Subject: absurl: export a base url var for testing --- transform/absurl.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'transform') diff --git a/transform/absurl.go b/transform/absurl.go index 89727a705..75dbe4db3 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) }) } -- cgit v1.2.3