if prefix != "" {
hasPrefix := false
// avoid adding language prefix if already present
+ in2 := in
if strings.HasPrefix(in, "/") {
- hasPrefix = strings.HasPrefix(in[1:], prefix)
+ in2 = in[1:]
+ }
+ if in2 == prefix {
+ hasPrefix = true
} else {
- hasPrefix = strings.HasPrefix(in, prefix)
+ hasPrefix = strings.HasPrefix(in2, prefix+"/")
}
if !hasPrefix {
if prefix != "" {
hasPrefix := false
// avoid adding language prefix if already present
+ in2 := in
if strings.HasPrefix(in, "/") {
- hasPrefix = strings.HasPrefix(in[1:], prefix)
+ in2 = in[1:]
+ }
+ if in2 == prefix {
+ hasPrefix = true
} else {
- hasPrefix = strings.HasPrefix(in, prefix)
+ hasPrefix = strings.HasPrefix(in2, prefix+"/")
}
if !hasPrefix {
{"http//foo", "http://base/path", "http://base/path/MULTIhttp/foo"},
}
+ if multilingual && addLanguage && defaultInSubDir {
+ newTests := []struct {
+ input string
+ baseURL string
+ expected string
+ }{
+ {lang + "test", "http://base/", "http://base/" + lang + "/" + lang + "test"},
+ {"/" + lang + "test", "http://base/", "http://base/" + lang + "/" + lang + "test"},
+ }
+
+ for _, test := range newTests {
+ tests = append(tests, test)
+ }
+ }
+
for _, test := range tests {
v.Set("baseURL", test.baseURL)
v.Set("contentDir", "content")
{"//schemaless", "http://base/", false, "//schemaless"},
}
+ if multilingual && addLanguage && defaultInSubDir {
+ newTests := []struct {
+ input string
+ baseURL string
+ canonify bool
+ expected string
+ }{
+ {lang + "test", "http://base/", false, "/" + lang + "/" + lang + "test"},
+ {"/" + lang + "test", "http://base/", false, "/" + lang + "/" + lang + "test"},
+ }
+
+ for _, test := range newTests {
+ tests = append(tests, test)
+ }
+ }
+
for i, test := range tests {
v.Set("baseURL", test.baseURL)
v.Set("canonifyURLs", test.canonify)