diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2015-05-01 12:29:10 +0200 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-05-01 12:29:03 +0200 |
commit | be049ff96ad5c5af1192316b43a2e9577ef0b065 (patch) | |
tree | 49173d51c00e4025e3ac7fbbabf5ba6e73b42a52 /transform/absurl.go | |
parent | be9df847723f414770d38c071eada0cbe646b4e3 (diff) |
absurl: export a base url var for testing
Diffstat (limited to 'transform/absurl.go')
-rw-r--r-- | transform/absurl.go | 13 |
1 files changed, 12 insertions, 1 deletions
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) }) } |