aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-12-08 20:59:52 +0300
committerManeraKai <manerakai@protonmail.com>2022-12-08 20:59:52 +0300
commit2a738e883c5c48207a1f9e737feb3ce53fdd969b (patch)
tree717d779a6441c23440a0afdd68decd5758cd1e29
parentconverted the search keyword from 'libredirect' to '@libredirect' https://git... (diff)
downloadlibredirect-2a738e883c5c48207a1f9e737feb3ce53fdd969b.zip
Added Url Parameters support for Invidious, Piped https://github.com/libredirect/libredirect/issues/491
Diffstat (limited to '')
-rw-r--r--src/assets/javascripts/services.js9
-rw-r--r--src/assets/javascripts/utils.js2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index c59e4344..0b418f91 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -97,6 +97,9 @@ function redirect(url, type, initiator, forceRedirection) {
break
}
if (!frontend || !randomInstance) return
+ let randomInstanceURL = new URL(randomInstance);
+ let allParams = randomInstanceURL.searchParams
+ url.searchParams.forEach((value, key) => allParams.append(key, value))
// Here is a (temperory) space for defining constants required in 2 or more switch cases.
// When possible, try have the two switch cases share all their code as done with searx and searxng.
@@ -116,7 +119,6 @@ function redirect(url, type, initiator, forceRedirection) {
}
return [zoom, lon, lat]
}
- console.log(frontend)
switch (frontend) {
// This is where all instance-specific code must be ran to convert the service url to one that can be understood by the frontend.
case "beatbump":
@@ -447,8 +449,11 @@ function redirect(url, type, initiator, forceRedirection) {
return `${randomInstance}${url.pathname}${url.search}`
case "simpleertube":
return `${randomInstance}/${url.hostname}${url.pathname}${url.search}`
+ case "invidious":
+ case "piped":
+ return `${utils.protocolHost(randomInstanceURL)}${url.pathname}?${allParams.toString()}`
default:
- return `${randomInstance}${url.pathname}${url.search} `
+ return `${randomInstance}${url.pathname}${url.search}`
}
}
diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js
index 2b69e9a6..dce7f349 100644
--- a/src/assets/javascripts/utils.js
+++ b/src/assets/javascripts/utils.js
@@ -188,7 +188,7 @@ async function processDefaultCustomInstances(service, frontend, network, documen
event.preventDefault()
let frontendCustomInstanceInput = frontendNetworkElement.getElementsByClassName("custom-instance")[0]
let url = new URL(frontendCustomInstanceInput.value)
- let protocolHostVar = protocolHost(url)
+ let protocolHostVar = url.href
if (frontendCustomInstanceInput.validity.valid && !redirects[frontend][network].includes(protocolHostVar)) {
if (!frontendCustomInstances.includes(protocolHostVar)) {
frontendCustomInstances.push(protocolHostVar)