Skip to content

Commit

Permalink
fix(router): a route with path '/' breaks handleUnknownRoutes
Browse files Browse the repository at this point in the history
Strip leading slash from route paths before registering child handlers to avoid adding bad route paths to child recognizers.

fixes #116
  • Loading branch information
bryanrsmith committed Jun 23, 2015
1 parent 9f97925 commit adf30dc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,20 @@ export class Router {
}

this.routes.push(config);
let state = this.recognizer.add({path:config.route, handler: config});

if (config.route) {
let path = config.route;
if (path.charAt(0) === '/') {
path = path.substr(1);
}

let state = this.recognizer.add({path: path, handler: config});

if (path) {
let withChild, settings = config.settings;
delete config.settings;
withChild = JSON.parse(JSON.stringify(config));
config.settings = settings;
withChild.route += '/*childRoute';
withChild.route = `${path}/*childRoute`;
withChild.hasChildRouter = true;
this.childRecognizer.add({
path: withChild.route,
Expand Down

0 comments on commit adf30dc

Please sign in to comment.