1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 04:51:56 +00:00

support multi-level subdomains redirect, see previous commit for the SubdomainRedirect fast solution

Former-commit-id: bc5749e46d1ae65f9d17063f3d8f2ea72510a9d8
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-01-20 14:54:04 +02:00
parent e176ff7b0c
commit 25918427bc
5 changed files with 12 additions and 5 deletions

View File

@@ -129,7 +129,10 @@ func hasSubdomain(s string) bool {
// if not start with "/" then it should be something else,
// we don't assume anything else but subdomain.
slashIdx := strings.IndexByte(s, '/')
return slashIdx > 0 || s[0] == SubdomainPrefix[0] || (len(s) >= 2 && s[0:2] == SubdomainWildcardIndicator)
return slashIdx > 0 || // for route paths
s[0] == SubdomainPrefix[0] || // for route paths
(len(s) >= 2 && s[0:2] == SubdomainWildcardIndicator) || // for party rel path or route paths
(len(s) >= 2 && slashIdx != 0 && s[len(s)-1] == '.') // for party rel, i.e www., or subsub.www.
}
// splitSubdomainAndPath checks if the path has subdomain and if it's