diff options
| author | Igor Minar | 2011-09-21 13:47:17 +0200 |
|---|---|---|
| committer | Igor Minar | 2011-09-27 01:45:54 +0200 |
| commit | f7a5f1788a794d082a05e48f728b22b47a6cc622 (patch) | |
| tree | cf4db4364489f3b3e1bfb9b19a9a09ce3812c08b /src | |
| parent | b3ed7a8a7a45882751407fbb645302ee14ce1a79 (diff) | |
| download | angular.js-f7a5f1788a794d082a05e48f728b22b47a6cc622.tar.bz2 | |
fix($route): fix regex escaping in route matcher
Diffstat (limited to 'src')
| -rw-r--r-- | src/service/route.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/service/route.js b/src/service/route.js index 2634eb6c..9f0c7b6d 100644 --- a/src/service/route.js +++ b/src/service/route.js @@ -197,14 +197,16 @@ angularServiceInject('$route', function(location, $updateView) { function switchRouteMatcher(on, when, dstName) { - 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); } } |
