mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
f53145b274
commit
74ffb45fbe
1 changed files with 28 additions and 24 deletions
|
@ -169,20 +169,22 @@ func AbsURL(in string, addLanguage bool) string {
|
||||||
|
|
||||||
if addLanguage {
|
if addLanguage {
|
||||||
prefix := getLanguagePrefix()
|
prefix := getLanguagePrefix()
|
||||||
hasPrefix := false
|
if prefix != "" {
|
||||||
// avoid adding language prefix if already present
|
hasPrefix := false
|
||||||
if strings.HasPrefix(in, "/") {
|
// avoid adding language prefix if already present
|
||||||
hasPrefix = strings.HasPrefix(in[1:], prefix)
|
if strings.HasPrefix(in, "/") {
|
||||||
} else {
|
hasPrefix = strings.HasPrefix(in[1:], prefix)
|
||||||
hasPrefix = strings.HasPrefix(in, prefix)
|
} else {
|
||||||
}
|
hasPrefix = strings.HasPrefix(in, prefix)
|
||||||
|
}
|
||||||
|
|
||||||
if prefix != "" && !hasPrefix {
|
if !hasPrefix {
|
||||||
addSlash := in == "" || strings.HasSuffix(in, "/")
|
addSlash := in == "" || strings.HasSuffix(in, "/")
|
||||||
in = path.Join(prefix, in)
|
in = path.Join(prefix, in)
|
||||||
|
|
||||||
if addSlash {
|
if addSlash {
|
||||||
in += "/"
|
in += "/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,21 +233,23 @@ func RelURL(in string, addLanguage bool) string {
|
||||||
|
|
||||||
if addLanguage {
|
if addLanguage {
|
||||||
prefix := getLanguagePrefix()
|
prefix := getLanguagePrefix()
|
||||||
hasPrefix := false
|
if prefix != "" {
|
||||||
// avoid adding language prefix if already present
|
hasPrefix := false
|
||||||
if strings.HasPrefix(in, "/") {
|
// avoid adding language prefix if already present
|
||||||
hasPrefix = strings.HasPrefix(in[1:], prefix)
|
if strings.HasPrefix(in, "/") {
|
||||||
} else {
|
hasPrefix = strings.HasPrefix(in[1:], prefix)
|
||||||
hasPrefix = strings.HasPrefix(in, prefix)
|
} else {
|
||||||
}
|
hasPrefix = strings.HasPrefix(in, prefix)
|
||||||
|
}
|
||||||
|
|
||||||
if prefix != "" && !hasPrefix {
|
if !hasPrefix {
|
||||||
hadSlash := strings.HasSuffix(u, "/")
|
hadSlash := strings.HasSuffix(u, "/")
|
||||||
|
|
||||||
u = path.Join(prefix, u)
|
u = path.Join(prefix, u)
|
||||||
|
|
||||||
if hadSlash {
|
if hadSlash {
|
||||||
u += "/"
|
u += "/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue