Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function setBadge(text, color) {
async function checkServerStatus() {
try {
const { url } = await getCredentials();
if (!url || url === 'undefined://undefined:undefined') {
if (!url || url === 'undefined://undefined:undefined' || url === 'undefined://undefined') {
setBadge('?', '#888'); // Gray - not configured
return false;
}
Expand All @@ -31,10 +31,14 @@ async function checkServerStatus() {

async function getCredentials() {
const credentials = await browser.storage.local.get(['apiScheme', 'apiHost', 'apiPort', 'apiUsername', 'apiPassword']);
const portSuffix = credentials.apiPort != null && credentials.apiPort !== ''
? `:${credentials.apiPort}`
: '';

return {
username: credentials.apiUsername,
password: credentials.apiPassword,
url: `${credentials.apiScheme}://${credentials.apiHost}:${credentials.apiPort}`,
url: `${credentials.apiScheme}://${credentials.apiHost}${portSuffix}`,
credentials: credentials
};
}
Expand Down Expand Up @@ -246,3 +250,4 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
loginTabs.delete(tabId);
}
});