Added support for trailing slashes in routes

m.route now matches a path with a trailing slash against a route without one.
This commit is contained in:
Sebastian 2014-05-22 14:41:21 +02:00
parent 67c5400d44
commit d10d77288c
2 changed files with 17 additions and 2 deletions

View file

@ -573,6 +573,21 @@ function testMithril(mock) {
mock.performance.$elapse(50) //teardown
return root.childNodes[0].nodeValue === "foo bar"
})
test(function() {
mock.performance.$elapse(50) //setup
mock.location.search = "?"
var root = mock.document.createElement("div")
m.route.mode = "search"
m.route(root, "/", {
"/": {controller: function() {}, view: function() {return "foo"}},
"/test11": {controller: function() {}, view: function() {return "bar"}}
})
mock.performance.$elapse(50)
m.route("/test11/")
mock.performance.$elapse(50) //teardown
return mock.location.search == "?/test11/" && root.childNodes[0].nodeValue === "bar"
})
//end m.route
//m.prop