Skip to content

Commit

Permalink
Merge pull request julienschmidt#65 from oov/fix-panic
Browse files Browse the repository at this point in the history
tree: fix panic in non-ascii routes
  • Loading branch information
julienschmidt committed Mar 21, 2015
2 parents ddb6c34 + 7988dc1 commit b56ed26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (n *node) addRoute(path string, handle Handle) {
}

n.children = []*node{&child}
n.indices = string(n.path[i])
n.indices = string([]byte{n.path[i]})
n.path = path[:i]
n.handle = nil
n.wildChild = false
Expand Down Expand Up @@ -169,7 +169,7 @@ func (n *node) addRoute(path string, handle Handle) {

// Otherwise insert it
if c != ':' && c != '*' {
n.indices += string(c)
n.indices += string([]byte{c})
child := &node{
maxParams: numParams,
}
Expand Down
4 changes: 4 additions & 0 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func TestTreeAddAndGet(t *testing.T) {
"/doc/",
"/doc/go_faq.html",
"/doc/go1.html",
"/α",
"/β",
}
for _, route := range routes {
tree.addRoute(route, fakeHandler(route))
Expand All @@ -142,6 +144,8 @@ func TestTreeAddAndGet(t *testing.T) {
{"/cona", true, "", nil}, // key mismatch
{"/no", true, "", nil}, // no matching child
{"/ab", false, "/ab", nil},
{"/α", false, "/α", nil},
{"/β", false, "/β", nil},
})

checkPriorities(t, tree)
Expand Down

0 comments on commit b56ed26

Please sign in to comment.