diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-05 10:20:06 +0700 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-17 17:15:26 +0100 |
commit | 93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch) | |
tree | 5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /helpers/url.go | |
parent | e34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff) |
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables
the use if `t.Parallel` in tests.
Updates #2701
Fixes #3016
Diffstat (limited to 'helpers/url.go')
-rw-r--r-- | helpers/url.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/helpers/url.go b/helpers/url.go index 2f35b059f..3a060eee9 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -21,7 +21,6 @@ import ( "github.com/PuerkitoBio/purell" jww "github.com/spf13/jwalterweatherman" - "github.com/spf13/viper" ) type pathBridge struct { @@ -158,7 +157,7 @@ func (p *PathSpec) AbsURL(in string, addLanguage bool) string { return in } - baseURL := viper.GetString("baseURL") + baseURL := p.baseURL if strings.HasPrefix(in, "/") { p, err := url.Parse(baseURL) if err != nil { @@ -200,7 +199,7 @@ func (p *PathSpec) getLanguagePrefix() string { defaultLang := p.defaultContentLanguage defaultInSubDir := p.defaultContentLanguageInSubdir - currentLang := p.currentContentLanguage.Lang + currentLang := p.language.Lang if currentLang == "" || (currentLang == defaultLang && !defaultInSubDir) { return "" } @@ -220,7 +219,7 @@ func IsAbsURL(path string) bool { // RelURL creates a URL relative to the BaseURL root. // Note: The result URL will not include the context root if canonifyURLs is enabled. func (p *PathSpec) RelURL(in string, addLanguage bool) string { - baseURL := viper.GetString("baseURL") + baseURL := p.baseURL canonifyURLs := p.canonifyURLs if (!strings.HasPrefix(in, baseURL) && strings.HasPrefix(in, "http")) || strings.HasPrefix(in, "//") { return in |