aboutsummaryrefslogtreecommitdiffstats
path: root/src/service/route.js
diff options
context:
space:
mode:
authorIgor Minar2011-09-21 13:47:17 +0200
committerIgor Minar2011-09-21 13:47:17 +0200
commit2bc39bb0b4f81b77597bb52f8572d231cf4f83e2 (patch)
tree69e493793b2d6af6712429a2a55232d1db746e3e /src/service/route.js
parent62ae7fccbc524ff498779564294ed6e1a7a3f51c (diff)
downloadangular.js-2bc39bb0b4f81b77597bb52f8572d231cf4f83e2.tar.bz2
fix($route): fix regex escaping in route matcher
Diffstat (limited to 'src/service/route.js')
-rw-r--r--src/service/route.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/service/route.js b/src/service/route.js
index c12ce99d..73c73b04 100644
--- a/src/service/route.js
+++ b/src/service/route.js
@@ -235,14 +235,16 @@ angularServiceInject('$route', function($location, $routeParams) {
/////////////////////////////////////////////////////
function switchRouteMatcher(on, when) {
- var regex = '^' + when.replace(/[\.\\\(\)\^\$]/g, "\$1") + '$',
+ // TODO(i): this code is convoluted and inefficient, we should construct the route matching
+ // regex only once and then reuse it
+ var regex = '^' + when.replace(/([\.\\\(\)\^\$])/g, "\\$1") + '$',
params = [],
dst = {};
forEach(when.split(/\W/), function(param) {
if (param) {
var paramRegExp = new RegExp(":" + param + "([\\W])");
if (regex.match(paramRegExp)) {
- regex = regex.replace(paramRegExp, "([^\/]*)$1");
+ regex = regex.replace(paramRegExp, "([^\\/]*)$1");
params.push(param);
}
}