From 30a0b242587514e8e1265ef7313bed9c07b24bbf Mon Sep 17 00:00:00 2001 From: teddit Date: Sat, 28 Nov 2020 17:37:18 +0100 Subject: [PATCH] fix an issue when url is undefined and post won't load --- app.js | 2 +- inc/downloadAndSave.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 5c28d41..7c844e5 100644 --- a/app.js +++ b/app.js @@ -82,7 +82,7 @@ if(redirect_www) { if(req.headers.host) { if(req.headers.host.slice(0, 4) === 'www.') { let newhost = req.headers.host.slice(4) - return res.redirect(301, req.protocol + '://' + newhost + req.originalUrl) + return res.redirect(301, `${req.protocol}://${newhost}${req.originalUrl}`) } } next() diff --git a/inc/downloadAndSave.js b/inc/downloadAndSave.js index ed06adc..911d240 100644 --- a/inc/downloadAndSave.js +++ b/inc/downloadAndSave.js @@ -17,7 +17,7 @@ module.exports = function(tools) { * https://teddit.net/vids/f3lcdk4ydcl51.mp4 */ let valid_video_extensions = ['mp4', 'webm', 'ogg'] - let invalid_urls = ['self', 'default', 'nsfw', 'image', 'spoiler'] + let invalid_urls = ['self', 'default', 'nsfw', 'image', 'spoiler', 'undefined', undefined, null, ''] return new Promise((resolve, reject) => { if(!invalid_urls.includes(url)) { (async () => {