From a3f3c4b041e7216d596ed5fff14826a9a781a833 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 26 Feb 2018 12:02:44 -0700 Subject: [PATCH] workaround for malforrmed url --- README.md | 15 --------------- index.js | 8 +++++++- package.json | 10 +++++----- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 106c8f3..2635d1c 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,3 @@ - - -About Daplie: We're taking back the Internet! --------------- - -Down with Google, Apple, and Facebook! - -We're re-decentralizing the web and making it read-write again - one home cloud system at a time. - -Tired of serving the Empire? Come join the Rebel Alliance: - -jobs@daplie.com | [Invest in Daplie on Wefunder](https://daplie.com/invest/) | [Pre-order Cloud](https://daplie.com/preorder/), The World's First Home Server for Everyone - - - # redirect-https Redirect from HTTP to HTTPS using meta redirects diff --git a/index.js b/index.js index b9a4182..cc7e252 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,14 @@ module.exports = function (opts) { ; //var encodedLocation = encodeURI(newLocation); var escapedLocation = escapeHtml(newLocation); + var encodedLocation; + try { + encodedLocation = decodeURIComponent(newLocation); + } catch(e) { + encodedLocation = "#/error/?error_message=" + e.toString(); + } var body = opts.body - .replace(/{{\s*HTML_URL\s*}}/ig, escapeHtml(decodeURIComponent(newLocation))) + .replace(/{{\s*HTML_URL\s*}}/ig, escapeHtml(encodedLocation)) .replace(/{{\s*URL\s*}}/ig, escapedLocation) .replace(/{{\s*UNSAFE_URL\s*}}/ig, newLocation) ; diff --git a/package.json b/package.json index 625ff3c..44fca19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redirect-https", - "version": "1.1.1", + "version": "1.1.2", "description": "Redirect from HTTP to HTTPS using meta redirects", "main": "index.js", "scripts": { @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Daplie/node-redirect-https.git" + "url": "git+https://git.coolaj86.com/coolaj86/redirect-https.js.git" }, "keywords": [ "https", @@ -22,10 +22,10 @@ "author": "AJ ONeal (http://coolaj86.com/)", "license": "Apache-2.0", "bugs": { - "url": "https://github.com/Daplie/node-redirect-https/issues" + "url": "https://git.coolaj86.com/coolaj86/redirect-https.js/issues" }, - "homepage": "https://github.com/Daplie/node-redirect-https#readme", + "homepage": "https://git.coolaj86.com/coolaj86/redirect-https.js#readme", "dependencies": { - "escape-html": "^1.0.2" + "escape-html": "^1.0.3" } }