From 87722144b6ac563dc1fed4f5a647e74eb121b4ae Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Fri, 15 Jan 2016 22:41:12 +0000 Subject: Add Base64 Decode feature. Simplify UI --- css/redirector.css | 4 ++++ js/redirect.js | 27 +++++++++++++++++---------- redirector.html | 19 +++++++++++++------ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/css/redirector.css b/css/redirector.css index 97b877c..9417eb1 100644 --- a/css/redirector.css +++ b/css/redirector.css @@ -416,6 +416,10 @@ a.disabled:hover { margin-top:2px; } +.advanced div .input-cell select { + margin-top:4px; + width:160px; +} a[ng-click] { cursor:pointer; diff --git a/js/redirect.js b/js/redirect.js index c9036e1..718d5f2 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -23,6 +23,7 @@ Redirect.requestTypes = { other : "Other" }; + Redirect.prototype = { //attributes @@ -34,8 +35,7 @@ Redirect.prototype = { excludePattern : '', redirectUrl : '', patternType : '', - unescapeMatches : false, - escapeMatches : false, + processMatches : 'noProcessing', disabled : false, compile : function() { @@ -58,8 +58,7 @@ Redirect.prototype = { && this.excludePattern == redirect.excludePattern && this.redirectUrl == redirect.redirectUrl && this.patternType == redirect.patternType - && this.unescapeMatches == redirect.unescapeMatches - && this.escapeMatches == redirect.escapeMatches + && this.processMatches == redirect.processMatches && this.appliesTo.toString() == redirect.appliesTo.toString(); }, @@ -73,8 +72,7 @@ Redirect.prototype = { excludePattern : this.excludePattern, redirectUrl : this.redirectUrl, patternType : this.patternType, - unescapeMatches : this.unescapeMatches, - escapeMatches : this.escapeMatches, + processMatches : this.processMatches, disabled : this.disabled, appliesTo : this.appliesTo.slice(0) }; @@ -210,8 +208,14 @@ Redirect.prototype = { this.excludePattern = o.excludePattern || ''; this.redirectUrl = o.redirectUrl || ''; this.patternType = o.patternType || Redirect.WILDCARD; - this.unescapeMatches = !!o.unescapeMatches; - this.escapeMatches = !!o.escapeMatches; + this.processMatches = o.processMatches || 'noProcessing'; + if (!o.processMatches && o.unescapeMatches) { + this.processMatches = 'urlDecode'; + } + if (!o.processMatches && o.escapeMatches) { + this.processMatches = 'urlEncode'; + } + this.disabled = !!o.disabled; if (o.appliesTo && o.appliesTo.length) { this.appliesTo = o.appliesTo.slice(0); @@ -235,12 +239,15 @@ Redirect.prototype = { var resultUrl = this.redirectUrl; for (var i = 1; i < matches.length; i++) { var repl = matches[i] || ''; - if (this.unescapeMatches) { + if (this.processMatches == 'urlDecode') { repl = unescape(repl); } - if (this.escapeMatches) { + if (this.processMatches == 'urlEncode') { repl = encodeURIComponent(repl); } + if (this.processMatches == 'base64decode') { + repl = atob(repl); + } resultUrl = resultUrl.replace(new RegExp('\\$' + i, 'gi'), repl); } this._rxInclude.lastIndex = 0; diff --git a/redirector.html b/redirector.html index 8483a02..164a8b5 100644 --- a/redirector.html +++ b/redirector.html @@ -85,12 +85,19 @@
- -
E.g. turn %2Fbar%2Ffoo%3Fx%3D2 into /bar/foo?x=2
-
-
- -
E.g. turn /bar/foo?x=2 into %2Fbar%2Ffoo%3Fx%3D2
+ +
+ + Use matches as they are + E.g. turn /bar/foo?x=2 into %2Fbar%2Ffoo%3Fx%3D2 + E.g. turn %2Fbar%2Ffoo%3Fx%3D2 into /bar/foo?x=2 + E.g. turn aHR0cDovL2Nubi5jb20= into http://cnn.com +
-- cgit v1.2.3