From 3edde76303636d049ea8ea823d7b1ad795cb008b Mon Sep 17 00:00:00 2001 From: teddit Date: Sat, 21 Nov 2020 12:40:31 +0100 Subject: [PATCH] fix error while trying to localize an URL --- views/includes/head.pug | 10 ++++++---- views/post.pug | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/views/includes/head.pug b/views/includes/head.pug index 909a72f..d23d899 100644 --- a/views/includes/head.pug +++ b/views/includes/head.pug @@ -70,10 +70,12 @@ meta(name="viewport", content="width=device-width, initial-scale=1.0") } function localize(url) { - let u = new URL(url) - if(u.host === 'www.reddit.com' || u.host === 'reddit.com') { - url = url.replace(u.host, 'teddit.net') - } + try { + let u = new URL(url) + if(u.host === 'www.reddit.com' || u.host === 'reddit.com') { + url = url.replace(u.host, 'teddit.net') + } + } catch(e) { } return url } diff --git a/views/post.pug b/views/post.pug index 6bb3dc4..bf51a7e 100644 --- a/views/post.pug +++ b/views/post.pug @@ -93,7 +93,6 @@ html p YouTube video info: p #{post.media.title} #{post.media.embed_src} p #{post.media.author_name} #{post.media.author_url} - p else if post.media.source === 'external' if post.images