From 8828f1ca973e729eaed679c3c2c868c65b36b501 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 26 Aug 2024 15:30:44 +0300 Subject: [PATCH] Added support for subdirectory https://github.com/libredirect/browser_extension/issues/875 --- src/assets/javascripts/utils.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 756b0d0..36271a8 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -24,11 +24,14 @@ function getNextInstance(currentInstanceUrl, instances) { * @param {URL} url */ function protocolHost(url) { - if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}` + url.pathname = url.pathname.replace(/\/$/, ''); + if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}${url.pathname}` + + // workaround if (url.pathname == "/TekstoLibre/" && url.host.endsWith("github.io")) - // workaround return `${url.protocol}//${url.host}${url.pathname.slice(0, -1)}` - return `${url.protocol}//${url.host}` + + return `${url.protocol}//${url.host}${url.pathname}` } /** @@ -221,5 +224,5 @@ export default { addressToLatLng, getQuery, prefsEncoded, - convertMapCentre + convertMapCentre, }