Stale isEqual for now

pull/230/head
Fenny 2020-03-17 13:24:08 +01:00
parent 3cea91e3da
commit 5c619e872c
2 changed files with 8 additions and 8 deletions

View File

@ -83,7 +83,7 @@ func (r *Route) matchRoute(method, path string) (match bool, values []string) {
// non-middleware route, http method must match!
// the wildcard method is for .All() & .Use() methods
// If route is GET, also match HEAD requests
if r.Method == method || r.Method[0] == '*' || (r.isGet && isEqual(method, "HEAD")) {
if r.Method == method || r.Method[0] == '*' || (r.isGet && len(method) == 4 && method == "HEAD") {
// '*' means we match anything
if r.isStar {
return true, values
@ -109,7 +109,7 @@ func (r *Route) matchRoute(method, path string) (match bool, values []string) {
return true, values
}
// last thing to do is to check for a simple path match
if isEqual(r.Path, path) {
if len(r.Path) == len(path) && r.Path == path {
return true, values
}
}

View File

@ -41,12 +41,12 @@ func groupPaths(prefix, path string) string {
// BenchmarkDefault 322504144 18.6 ns/op // string == string
// BenchmarkisEqual 353663168 17.0 ns/op // isEqual(string, string)
func isEqual(a, b string) bool {
if len(a) == len(b) {
return a == b
}
return false
}
// func isEqual(a, b string) bool {
// if len(a) == len(b) {
// return a == b
// }
// return false
// }
func getParams(path string) (params []string) {
if len(path) < 1 {