tree: fix panic in non-ascii routes
http://golang.org/ref/spec#Conversions_to_and_from_a_string_type
string(0xce) == "\xc3\x8e"
string([]byte{0xce}) == "\xce"
Example: http://play.golang.org/p/nVEixeJjHS
diff --git a/tree.go b/tree.go
index af91966..47af948 100644
--- a/tree.go
+++ b/tree.go
@@ -118,7 +118,7 @@
}
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
@@ -169,7 +169,7 @@
// Otherwise insert it
if c != ':' && c != '*' {
- n.indices += string(c)
+ n.indices += string([]byte{c})
child := &node{
maxParams: numParams,
}
diff --git a/tree_test.go b/tree_test.go
index 484621e..262681b 100644
--- a/tree_test.go
+++ b/tree_test.go
@@ -125,6 +125,8 @@
"/doc/",
"/doc/go_faq.html",
"/doc/go1.html",
+ "/α",
+ "/β",
}
for _, route := range routes {
tree.addRoute(route, fakeHandler(route))
@@ -142,6 +144,8 @@
{"/cona", true, "", nil}, // key mismatch
{"/no", true, "", nil}, // no matching child
{"/ab", false, "/ab", nil},
+ {"/α", false, "/α", nil},
+ {"/β", false, "/β", nil},
})
checkPriorities(t, tree)