fix an issue when url is undefined and post won't load

This commit is contained in:
teddit 2020-11-28 17:37:18 +01:00
parent 972865d50f
commit 30a0b24258
2 changed files with 2 additions and 2 deletions

2
app.js
View File

@ -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()

View File

@ -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 () => {