From 4f1a686115275fab51e54ef9f445647ba17318e7 Mon Sep 17 00:00:00 2001 From: Robert Koritnik Date: Wed, 22 Jan 2014 02:41:39 +0100 Subject: [PATCH] Added support for route parameter regular expression constraints Added support for route parameter regular expression constraints --- src/ngRoute/route.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ngRoute/route.js b/src/ngRoute/route.js index 2d7ce8e40a3e..6f441ec9ba04 100644 --- a/src/ngRoute/route.js +++ b/src/ngRoute/route.js @@ -185,7 +185,7 @@ function $RouteProvider(){ path = path .replace(/([().])/g, '\\$1') - .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option){ + .replace(/(\/)?:(\w+)(?::([^\/]+))?([?*])?/g, function (_, slash, key, rxconstraint, option) { var optional = option === '?' ? option : null; var star = option === '*' ? option : null; keys.push({ name: key, optional: !!optional }); @@ -194,7 +194,7 @@ function $RouteProvider(){ + (optional ? '' : slash) + '(?:' + (optional ? slash : '') - + (star && '(.+?)' || '([^/]+)') + + (star && '(.+?)' || rxconstraint && ('(' + rxconstraint + ')') || '([^/]+)') + (optional || '') + ')' + (optional || '');