absurl: export a base url var for testing
authorbep <bjorn.erik.pedersen@gmail.com>
Fri, 1 May 2015 10:29:10 +0000 (12:29 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Fri, 1 May 2015 10:29:03 +0000 (12:29 +0200)
transform/absurl.go

index 89727a705689efbf9f47603303e5c3515bc0b38b..75dbe4db377baf161514f18136f0ca2a77558696 100644 (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)
        })
 }