diff --git a/lib/tarantino/router.js b/lib/tarantino/router.js index 8ed51d9..d169527 100644 --- a/lib/tarantino/router.js +++ b/lib/tarantino/router.js @@ -775,6 +775,7 @@ Router.prototype.mount = function(routes, path) { path = path || []; if (!Array.isArray(path)) { path = path.split(self.delimiter); + path = terminator(path, self.delimiter); } function insertOrMount(route, local) { @@ -791,6 +792,7 @@ Router.prototype.mount = function(routes, path) { if (isRoute && routeType === 'object' && !Array.isArray(routes[route])) { local = local.concat(parts); + local = terminator(local, self.delimiter); self.mount(routes[route], local); return; } diff --git a/test/server/core/mount-test.js b/test/server/core/mount-test.js index 3077628..739e7cc 100644 --- a/test/server/core/mount-test.js +++ b/test/server/core/mount-test.js @@ -85,6 +85,18 @@ vows.describe('tarantino/core/mount').addBatch({ '/api'); assertRoute(dogs, ['api', 'dogs', 'on'], router.routes); + }, + + "should fix unterminated RegExp groups": function(router) { + function cat () { } + + router.mount({ + '/(nyan/)?cat': { + on: cat + } + }); + + assertRoute(cat, ['(nyan/)?cat', 'on'], router.routes); } } },