From ee7508b24ae7a83eff8ecaecedcd402ebf07c266 Mon Sep 17 00:00:00 2001 From: analogue Date: Sun, 13 Mar 2022 22:13:21 +0000 Subject: [PATCH 1/2] When teddifying URLs to se for links, images, or video, use correct protocol scheme --- inc/commons.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inc/commons.js b/inc/commons.js index 6a78fa4..9745249 100644 --- a/inc/commons.js +++ b/inc/commons.js @@ -39,8 +39,10 @@ module.exports = function(request, fs) { this.teddifyUrl = (url, user_preferences) => { try { let u = new URL(url) + let domain_replaced = false if(u.host === 'www.reddit.com' || u.host === 'reddit.com') { url = url.replace(u.host, config.domain) + domain_replaced = true if(u.pathname.startsWith('/gallery/')) url = url.replace('/gallery/', '/comments/') } @@ -50,10 +52,15 @@ module.exports = function(request, fs) { let file_ext = getFileExtension(url) if(image_exts.includes(file_ext)) url = url.replace(`${u.host}/`, `${config.domain}/pics/w:null_`) + domain_replaced = true if(video_exts.includes(file_ext) || !image_exts.includes(file_ext)) url = url.replace(u.host, `${config.domain}/vids`) + '.mp4' + domain_replaced = true } + if(domain_replaced && !user_preferences.https_enabled) { + url = url.replace('https:', 'http:') + } } catch(e) { } url = replaceDomains(url, user_preferences) return url From 4bb02eaf03b000bacd082c380dc82e88ef75dc79 Mon Sep 17 00:00:00 2001 From: analogue Date: Tue, 29 Mar 2022 20:22:30 +0000 Subject: [PATCH 2/2] Use proper https_enabled flag --- inc/commons.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/commons.js b/inc/commons.js index 9745249..09846f6 100644 --- a/inc/commons.js +++ b/inc/commons.js @@ -58,7 +58,7 @@ module.exports = function(request, fs) { domain_replaced = true } - if(domain_replaced && !user_preferences.https_enabled) { + if(domain_replaced && !config.https_enabled) { url = url.replace('https:', 'http:') } } catch(e) { }