mirror of
https://github.com/Metastem/wikiless
synced 2024-12-06 19:16:58 +01:00
Fix: missing custom port on re-written links
When a link was rewritten and the site is running in a custom (ie, not protocol standard - http/80, https/443) port, the links became invalid. We now include them only when necessary.
This commit is contained in:
+2
-2
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user