aboutsummaryrefslogtreecommitdiff
path: root/js/redirect.js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2019-12-11 15:06:42 +0000
committerEinar Egilsson <einar@einaregilsson.com>2019-12-11 15:06:42 +0000
commit0fcc8c5e734d5e3ea769c5ef7be9f2200c3aca06 (patch)
treef724e430286791f867cf0c42c039ec362a04eac0 /js/redirect.js
parentb53d093463e94096f16f0fd7656fc88d642faa3d (diff)
More fixes after removing angular
Diffstat (limited to 'js/redirect.js')
-rw-r--r--js/redirect.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/js/redirect.js b/js/redirect.js
index 3bdf0f0..dfc59aa 100644
--- a/js/redirect.js
+++ b/js/redirect.js
@@ -155,6 +155,10 @@ Redirect.prototype = {
return;
}
+ if (match.isMatch && !match.redirectTo.match(/^https?\:\/\//)) {
+ this.error = 'The redirect result must start with http:// or https://, current result is: "' + match.redirectTo + ".";
+ return;
+ }
if (!match.isMatch) {
this.error = 'The include pattern does not match the example url.';
return;
@@ -241,6 +245,7 @@ Redirect.prototype = {
noProcessing : 'Use matches as they are',
urlEncode : 'E.g. turn /bar/foo?x=2 into %2Fbar%2Ffoo%3Fx%3D2',
urlDecode : 'E.g. turn %2Fbar%2Ffoo%3Fx%3D2 into /bar/foo?x=2',
+ doubleUrlDecode : 'E.g. turn %252Fbar%252Ffoo%253Fx%253D2 into /bar/foo?x=2',
base64Decode : 'E.g. turn aHR0cDovL2Nubi5jb20= into http://cnn.com'
};
@@ -264,11 +269,11 @@ Redirect.prototype = {
var repl = matches[i] || '';
if (this.processMatches == 'urlDecode') {
repl = unescape(repl);
- }
- if (this.processMatches == 'urlEncode') {
+ } else if (this.processMatches == 'doubleUrlDecode') {
+ repl = unescape(unescape(repl));
+ } else if (this.processMatches == 'urlEncode') {
repl = encodeURIComponent(repl);
- }
- if (this.processMatches == 'base64decode') {
+ } else if (this.processMatches == 'base64decode') {
if (repl.indexOf('%') > -1) {
repl = unescape(repl);
}