Skip to content

Commit

Permalink
Fixed a bug in Switch Instance #877
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Jan 8, 2024
1 parent b79a485 commit cfa6c88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,11 @@ function switchInstance(url, customService) {
if (customService) {
const instancesList = options[options[customService].frontend]
if (instancesList !== undefined) {
resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`)
const newInstance = utils.getNextInstance(url.origin, instancesList)
if (newInstance) {
resolve(`${newInstance}${url.pathname}${url.search}`)
return
}
}
} else {
for (const service in config.services) {
Expand All @@ -630,8 +634,11 @@ function switchInstance(url, customService) {
resolve()
return
}
resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`)
return
const newInstance = utils.getNextInstance(url.origin, instancesList)
if (newInstance) {
resolve(`${newInstance}${url.pathname}${url.search}`)
return
}
}
}
resolve()
Expand Down
4 changes: 1 addition & 3 deletions src/pages/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ browser.contextMenus.onClicked.addListener(async (info) => {
case 'switchInstanceTab': {
const url = new URL(info.pageUrl)
const newUrl = await servicesHelper.switchInstance(url)
if (newUrl) {
browser.tabs.update({ url: newUrl })
}
if (newUrl) browser.tabs.update({ url: newUrl })
return
}
case 'settingsTab': {
Expand Down

0 comments on commit cfa6c88

Please sign in to comment.