Fix URLs for bundle resources in multihost mode

Fixes #4217
This commit is contained in:
Bjørn Erik Pedersen
2018-01-05 12:01:13 +01:00
parent f25d8a9e17
commit ab82a27d05
6 changed files with 42 additions and 17 deletions

View File

@@ -35,8 +35,8 @@ type PathSpec struct {
uglyURLs bool
canonifyURLs bool
language *Language
languages Languages
Language *Language
Languages Languages
// pagination path handling
paginatePath string
@@ -70,7 +70,7 @@ type PathSpec struct {
}
func (p PathSpec) String() string {
return fmt.Sprintf("PathSpec, language %q, prefix %q, multilingual: %T", p.language.Lang, p.getLanguagePrefix(), p.multilingual)
return fmt.Sprintf("PathSpec, language %q, prefix %q, multilingual: %T", p.Language.Lang, p.getLanguagePrefix(), p.multilingual)
}
// NewPathSpec creats a new PathSpec from the given filesystems and Language.
@@ -113,8 +113,8 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
uglyURLs: cfg.GetBool("uglyURLs"),
canonifyURLs: cfg.GetBool("canonifyURLs"),
multilingual: cfg.GetBool("multilingual"),
language: language,
languages: languages,
Language: language,
Languages: languages,
defaultContentLanguageInSubdir: cfg.GetBool("defaultContentLanguageInSubdir"),
defaultContentLanguage: cfg.GetString("defaultContentLanguage"),
paginatePath: cfg.GetString("paginatePath"),

View File

@@ -50,7 +50,7 @@ func TestNewPathSpecFromConfig(t *testing.T) {
require.True(t, p.removePathAccents)
require.True(t, p.uglyURLs)
require.Equal(t, "no", p.defaultContentLanguage)
require.Equal(t, "no", p.language.Lang)
require.Equal(t, "no", p.Language.Lang)
require.Equal(t, "side", p.paginatePath)
require.Equal(t, "http://base.com", p.BaseURL.String())

View File

@@ -208,7 +208,7 @@ func (p *PathSpec) getLanguagePrefix() string {
defaultLang := p.defaultContentLanguage
defaultInSubDir := p.defaultContentLanguageInSubdir
currentLang := p.language.Lang
currentLang := p.Language.Lang
if currentLang == "" || (currentLang == defaultLang && !defaultInSubDir) {
return ""
}
@@ -221,7 +221,7 @@ func (p *PathSpec) GetLangSubDir(lang string) string {
return ""
}
if p.languages.IsMultihost() {
if p.Languages.IsMultihost() {
return ""
}