if addLanguage {
prefix := getLanguagePrefix()
- hasPrefix := false
- // avoid adding language prefix if already present
- if strings.HasPrefix(in, "/") {
- hasPrefix = strings.HasPrefix(in[1:], prefix)
- } else {
- hasPrefix = strings.HasPrefix(in, prefix)
- }
+ if prefix != "" {
+ hasPrefix := false
+ // avoid adding language prefix if already present
+ if strings.HasPrefix(in, "/") {
+ hasPrefix = strings.HasPrefix(in[1:], prefix)
+ } else {
+ hasPrefix = strings.HasPrefix(in, prefix)
+ }
- if prefix != "" && !hasPrefix {
- addSlash := in == "" || strings.HasSuffix(in, "/")
- in = path.Join(prefix, in)
+ if !hasPrefix {
+ addSlash := in == "" || strings.HasSuffix(in, "/")
+ in = path.Join(prefix, in)
- if addSlash {
- in += "/"
+ if addSlash {
+ in += "/"
+ }
}
}
}
if addLanguage {
prefix := getLanguagePrefix()
- hasPrefix := false
- // avoid adding language prefix if already present
- if strings.HasPrefix(in, "/") {
- hasPrefix = strings.HasPrefix(in[1:], prefix)
- } else {
- hasPrefix = strings.HasPrefix(in, prefix)
- }
+ if prefix != "" {
+ hasPrefix := false
+ // avoid adding language prefix if already present
+ if strings.HasPrefix(in, "/") {
+ hasPrefix = strings.HasPrefix(in[1:], prefix)
+ } else {
+ hasPrefix = strings.HasPrefix(in, prefix)
+ }
- if prefix != "" && !hasPrefix {
- hadSlash := strings.HasSuffix(u, "/")
+ if !hasPrefix {
+ hadSlash := strings.HasSuffix(u, "/")
- u = path.Join(prefix, u)
+ u = path.Join(prefix, u)
- if hadSlash {
- u += "/"
+ if hadSlash {
+ u += "/"
+ }
}
}
}