mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
cmd/cli: make widcard rules match case-insensitively
Domain name comparisons are done in case-insensitive manner. See: https://datatracker.ietf.org/doc/html/rfc1034#section-3.1
This commit is contained in:
committed by
Cuong Manh Le
parent
47a90ec2a1
commit
c654398981
@@ -630,14 +630,15 @@ func canonicalName(fqdn string) string {
|
||||
return q
|
||||
}
|
||||
|
||||
// wildcardMatches reports whether string str matches the wildcard pattern.
|
||||
// wildcardMatches reports whether string str matches the wildcard pattern in case-insensitive manner.
|
||||
func wildcardMatches(wildcard, str string) bool {
|
||||
// Wildcard match.
|
||||
wildCardParts := strings.Split(wildcard, "*")
|
||||
wildCardParts := strings.Split(strings.ToLower(wildcard), "*")
|
||||
if len(wildCardParts) != 2 {
|
||||
return false
|
||||
}
|
||||
|
||||
str = strings.ToLower(str)
|
||||
switch {
|
||||
case len(wildCardParts[0]) > 0 && len(wildCardParts[1]) > 0:
|
||||
// Domain must match both prefix and suffix.
|
||||
|
||||
Reference in New Issue
Block a user