remove the custom port logic from PR #2, let's use config.domain instead

This commit is contained in:
orenom
2021-05-27 19:58:32 +02:00
parent f8c3f1c6d1
commit deb0f20915
3 changed files with 3 additions and 5 deletions
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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) {
-2
View File
@@ -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)