Skip to content

Commit

Permalink
Add optional full URL handling for custom instances
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Bestavros <[email protected]>
  • Loading branch information
mbestavros committed Sep 11, 2024
1 parent f0b691f commit 2a3ddfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ function updateRules(parameterRedirectServices, customInstances) {
getRandomInstance(stackoverflowInstances);

function createRedirectRule(id, filter, instance) {
try {
uri = new URL(instance)
protocol = uri.protocol.slice(0, -1) //uri.protocol returns a trailing colon; slice that off
instance = uri.hostname
port = uri.port
} catch {
protocol = "https"
port = null
}
var transform = { scheme: protocol, host: instance, port: port }

return {
id: id,
priority: 1,
Expand All @@ -424,7 +435,7 @@ function updateRules(parameterRedirectServices, customInstances) {
action: {
type: "redirect",
redirect: {
transform: { scheme: "https", host: instance },
transform: transform,
},
},
};
Expand Down
File renamed without changes.

0 comments on commit 2a3ddfb

Please sign in to comment.