From e0d481043542860bdeccce47d3b0079165f77d21 Mon Sep 17 00:00:00 2001 From: Jonathan Baudanza Date: Tue, 17 May 2011 12:51:42 -0700 Subject: [PATCH] Resetting the value of lastIndex after a replace call. This is for the sake of IE --- src/davis.route.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/davis.route.js b/src/davis.route.js index 0593009..3e1c6d4 100644 --- a/src/davis.route.js +++ b/src/davis.route.js @@ -39,7 +39,13 @@ Davis.Route = (function () { var Route = function (method, path, callback) { var convertPathToRegExp = function () { if (!(path instanceof RegExp)) { - return new RegExp("^" + path.replace(pathNameRegex, pathNameReplacement) + "$", "gi"); + var str = path.replace(pathNameRegex, pathNameReplacement); + + // Most browsers will reset this to zero after a replace call. IE will + // set it to the index of the last matched character. + path.lastIndex = 0; + + return new RegExp("^" + str + "$", "gi"); } else { return path; };