Browse Source

Fix bug with string pattern matching with "."

Previously, a route like "/:a.png" would match "/foo/bar/baz.png".
This was incorrect, as all matches should be restricted to path segments
(or smaller, as dictated by a break character).

This bug was introduced in 1a390aba1c.

Fixes #75.
Carl Jackson 11 years ago
parent
commit
23ec88ea5a
2 changed files with 2 additions and 1 deletions
  1. +1
    -0
      web/pattern_test.go
  2. +1
    -1
      web/string_pattern.go

+ 1
- 0
web/pattern_test.go View File

@ -124,6 +124,7 @@ var patternTests = []struct {
pt("/a/cat", false, nil),
pt("/a/cat/gif", false, nil),
pt("/a/cat.", false, nil),
pt("/a/cat/dog.gif", false, nil),
}},
// String prefix tests


+ 1
- 1
web/string_pattern.go View File

@ -45,7 +45,7 @@ func (s stringPattern) match(r *http.Request, c *C, dryrun bool) bool {
m := 0
bc := s.breaks[i]
for ; m < len(path); m++ {
if path[m] == bc {
if path[m] == bc || path[m] == '/' {
break
}
}


Loading…
Cancel
Save