diff --git a/api/tests/test-router.js b/api/tests/test-router.js index 3efe9fa6b..8602fd688 100644 --- a/api/tests/test-router.js +++ b/api/tests/test-router.js @@ -225,6 +225,30 @@ o.spec("route", function() { ) }) + o("remove trailing slash to match route if it is before rest operator match (...) ", function() { + $window.location.href = prefix + "/test/d/" + route(root, "/test/some/path", { + "/test/:a" : { + view: lock(function(vnode) { + return JSON.stringify(route.param()) + " " + + JSON.stringify(vnode.attrs) + " " + + route.get() + }) + }, + "/test/:a..." : { + view: lock(function(vnode) { + return JSON.stringify(route.param()) + " " + + JSON.stringify(vnode.attrs) + " " + + route.get() + }) + }, + }) + + o(root.firstChild.nodeValue).equals( + '{"a":"d"} {"a":"d"} /test/d/' + ) + }) + o("handles route with search", function() { $window.location.href = prefix + "/test?a=b&c=d" route(root, "/test", { diff --git a/pathname/compileTemplate.js b/pathname/compileTemplate.js index 390c1e568..7a5950305 100644 --- a/pathname/compileTemplate.js +++ b/pathname/compileTemplate.js @@ -24,7 +24,7 @@ module.exports = function(template) { if (extra === ".") return "([^/]+)\\." return "([^/]+)" + (extra || "") } - ) + "$") + ) + "\\/?$") return function(data) { // First, check the params. Usually, there isn't any, and it's just // checking a static set.