summaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorbep <[email protected]>2015-05-01 12:29:10 +0200
committerbep <[email protected]>2015-05-01 12:29:03 +0200
commitbe049ff96ad5c5af1192316b43a2e9577ef0b065 (patch)
tree49173d51c00e4025e3ac7fbbabf5ba6e73b42a52 /transform
parentbe9df847723f414770d38c071eada0cbe646b4e3 (diff)
downloadhugo-be049ff96ad5c5af1192316b43a2e9577ef0b065.tar.gz
hugo-be049ff96ad5c5af1192316b43a2e9577ef0b065.zip
absurl: export a base url var for testing
Diffstat (limited to 'transform')
-rw-r--r--transform/absurl.go13
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)
})
}