From deb0f20915d9b3c4b18fd37fd4acbc6c1d3d5b83 Mon Sep 17 00:00:00 2001 From: orenom Date: Thu, 27 May 2021 19:58:32 +0200 Subject: [PATCH] remove the custom port logic from PR #2, let's use config.domain instead --- config.js.template | 2 +- src/utils.js | 4 ++-- src/wikiless.js | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/config.js.template b/config.js.template index bacc955..4d441ef 100644 --- a/config.js.template +++ b/config.js.template @@ -2,7 +2,7 @@ const config = { /** * Set these configs below to suite your environment. */ - domain: process.env.DOMAIN || '127.0.0.1', // Or for example 'wikiless.org' + domain: process.env.DOMAIN || '127.0.0.1', // Or for example 'wikiless.org' or '127.0.0.1:1337'. Remember to add port here if needed. default_lang: process.env.DEFAULT_LANG || 'en', theme: process.env.THEME || '', // '' or 'dark' nonssl_port: process.env.NONSSL_PORT || 8080, diff --git a/src/utils.js b/src/utils.js index b0b941c..6e8fa67 100644 --- a/src/utils.js +++ b/src/utils.js @@ -106,7 +106,7 @@ module.exports = function(redis) { let href = links[i].getAttribute('href') if(href) { if(href.startsWith('/wiki/') || href.startsWith('/w/')) { - href = `${protocol}${config.domain}${custom_port}${href}` + href = `${protocol}${config.domain}${href}` let u = new URL(href) u.searchParams.append('lang', lang) href = u.href @@ -146,7 +146,7 @@ module.exports = function(redis) { // replace wiki links const wiki_href_regx = /(href=\"(https:|http:|)\/\/([A-z.]+\.)?(wikipedia.org|wikimedia.org|wikidata.org|mediawiki.org))/gm - data.html = data.html.replace(wiki_href_regx, `href="${protocol}${config.domain}${custom_port}`) + data.html = data.html.replace(wiki_href_regx, `href="${protocol}${config.domain}`) redis.setex(url, config.setexs.wikipage, data.html, (error) => { if(error) { diff --git a/src/wikiless.js b/src/wikiless.js index a00e571..6a01969 100644 --- a/src/wikiless.js +++ b/src/wikiless.js @@ -48,10 +48,8 @@ if(config.https_enabled) { } https = require('https').Server(credentials, app) global.protocol = 'https://' - global.custom_port = config.ssl_port === '443' ? '' : `:${config.ssl_port}` } else { global.protocol = 'http://' - global.custom_port = config.nonssl_port === '80' ? '' : `:${config.nonssl_port}` } const http = require('http').Server(app)