From 30a9da5dc159dd1e19b677914356925c7ebdf632 Mon Sep 17 00:00:00 2001 From: Gonzalo Ruiz de Villa Date: Tue, 11 Dec 2012 11:41:53 +0100 Subject: fix($route): correctly extract $routeParams from urls Routes like '/bar/foovalue/barvalue' matching '/bar/:foo/:bar' now are well mapped in $routeParams to: {bar:'barvalue', foo:'foovalue'} Closes: #1501 Signed-off-by: Gonzalo Ruiz de Villa --- src/ng/route.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ng/route.js b/src/ng/route.js index e2a9c633..361b8ac3 100644 --- a/src/ng/route.js +++ b/src/ng/route.js @@ -321,12 +321,12 @@ function $RouteProvider(){ var regex = '^' + when.replace(/([\.\\\(\)\^\$])/g, "\\$1") + '$', params = [], dst = {}; - forEach(when.split(/\W/), function(param) { - if (param) { - var paramRegExp = new RegExp(":" + param + "([\\W])"); + forEach(when.split(/[^\w:]/), function(param) { + if (param && param.charAt(0) === ':') { + var paramRegExp = new RegExp(param + "([\\W])"); if (regex.match(paramRegExp)) { regex = regex.replace(paramRegExp, "([^\\/]*)$1"); - params.push(param); + params.push(param.substr(1)); } } }); -- cgit v1.2.3