diff options
author | Einar Egilsson <einar@einaregilsson.com> | 2014-09-07 17:50:28 +0000 |
---|---|---|
committer | Einar Egilsson <einar@einaregilsson.com> | 2014-09-07 17:50:28 +0000 |
commit | dfd5078d9e5789cac8e6e823803c93689be950ad (patch) | |
tree | 57c1c68f8b6c757c769090f96d09e014356d645a /chrome/js/redirect.js | |
parent | e2c1cd613cdfaaf4ae57d9024234748f30a3e80c (diff) | |
parent | dfa02f353906d63ee67d1924e5e4c39f615663a5 (diff) |
Merge branch 'master' of https://github.com/einaregilsson/Redirector
Diffstat (limited to 'chrome/js/redirect.js')
-rw-r--r-- | chrome/js/redirect.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chrome/js/redirect.js b/chrome/js/redirect.js index 4a05ef8..eab14f8 100644 --- a/chrome/js/redirect.js +++ b/chrome/js/redirect.js @@ -202,11 +202,14 @@ Redirect.prototype = { } var resultUrl = this.redirectUrl; for (var i = 1; i < matches.length; i++) { - resultUrl = resultUrl.replace(new RegExp('\\$' + i, 'gi'), - this.unescapeMatches ? unescape(matches[i]) : - this.escapeMatches ? encodeURIComponent(matches[i]) : - matches[i] - ); + var repl = matches[i] || ''; + if (this.unescapeMatches) { + repl = unescape(repl); + } + if (this.escapeMatches) { + repl = encodeURIComponent(repl); + } + resultUrl = resultUrl.replace(new RegExp('\\$' + i, 'gi'), repl); } this._rxInclude.lastIndex = 0; return resultUrl; |