diff --git a/src/utils.js b/src/utils.js index 6e8fa67..b0b941c 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}${href}` + href = `${protocol}${config.domain}${custom_port}${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}`) + data.html = data.html.replace(wiki_href_regx, `href="${protocol}${config.domain}${custom_port}`) redis.setex(url, config.setexs.wikipage, data.html, (error) => { if(error) { diff --git a/src/wikiless.js b/src/wikiless.js index 6a01969..a00e571 100644 --- a/src/wikiless.js +++ b/src/wikiless.js @@ -48,8 +48,10 @@ 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)