mirror of
https://github.com/kataras/iris.git
synced 2025-03-15 04:06:25 +01:00
minor
fix extreme test case on path_test when custom regexp double slashes Former-commit-id: a206cbb72e6740a5e050fae5267848f061efa463
This commit is contained in:
parent
0a29c2bfc8
commit
732a83ec6c
|
@ -232,12 +232,32 @@ func splitSubdomainAndPath(fullUnparsedPath string) (subdomain string, path stri
|
||||||
}
|
}
|
||||||
|
|
||||||
slashIdx := strings.IndexByte(s, '/')
|
slashIdx := strings.IndexByte(s, '/')
|
||||||
if slashIdx == 0 {
|
if slashIdx > 0 {
|
||||||
// no subdomain
|
// has subdomain
|
||||||
return "", s // cleanPath(s)
|
subdomain = s[0:slashIdx]
|
||||||
}
|
}
|
||||||
|
|
||||||
return s[0:slashIdx], s[slashIdx:] // cleanPath(s[slashIdx:]) // return subdomain without slash, path with slash
|
path = s[slashIdx:]
|
||||||
|
if !strings.Contains(path, "{") {
|
||||||
|
path = strings.ReplaceAll(path, "//", "/")
|
||||||
|
path = strings.ReplaceAll(path, "\\", "/")
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove any left trailing slashes, i.e "//api/users".
|
||||||
|
for i := 1; i < len(path); i++ {
|
||||||
|
if path[i] == '/' {
|
||||||
|
path = path[0:i] + path[i+1:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove last /.
|
||||||
|
path = strings.TrimRight(path, "/")
|
||||||
|
|
||||||
|
// no cleanPath(path) in order
|
||||||
|
// to be able to parse macro function regexp(\\).
|
||||||
|
return // return subdomain without slash, path with slash
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoutePathReverserOption option signature for the RoutePathReverser.
|
// RoutePathReverserOption option signature for the RoutePathReverser.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user