-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new case insensitive matcher #553
Changes from 1 commit
9e1e189
b77f9d9
53b26b2
972d851
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,7 @@ | |
# | ||
# prefix: prefix matching | ||
# glob: glob matching | ||
# nocase: matches using a case insensitive test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# | ||
# The default is | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ type matcher func(uri string, r *Route) bool | |
var Matcher = map[string]matcher{ | ||
"prefix": prefixMatcher, | ||
"glob": globMatcher, | ||
"noCase": noCaseMatcher, | ||
"nocase": noCaseMatcher, | ||
} | ||
|
||
// prefixMatcher matches path to the routes' path. | ||
|
@@ -27,5 +27,7 @@ func globMatcher(uri string, r *Route) bool { | |
|
||
// noCase matches path to the routes' path ignoring case | ||
func noCaseMatcher(uri string, r *Route) bool { | ||
return strings.EqualFold(uri, r.Path) | ||
lowerURI := strings.ToLower(uri) | ||
lowerPath := strings.ToLower(r.Path) | ||
return strings.HasPrefix(lowerURI, lowerPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After looking at this again, I think this should be a case insensitive prefix match. Originally I was using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // todo(fs): if this turns out to be a performance issue we should cache
// todo(fs): strings.ToLower(r.Path) in r.PathLower
return strings.HasPrefix(strings.ToLower(uri), strings.ToLower(r.Path)) |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With respect to the case-insensitive prefix matching I think
iprefix
is a better name.