Skip to content

Commit

Permalink
fix: Prevent throwing an exception if serviceUrl is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Nov 11, 2024
1 parent 9f996f1 commit e947a0b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion workers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,15 @@ const init = async () => {

let getServiceDomain = async () => {
let serviceUrl = await settings.get('serviceUrl');
let hostname = (new URL(serviceUrl).hostname || '').toString().toLowerCase().trim();
let parsedUrl;

try {
parsedUrl = new URL(serviceUrl);
} catch (err) {
parsedUrl = {};
}

let hostname = (parsedUrl.hostname || '').toString().toLowerCase().trim();
if (!hostname || net.isIP(hostname) || ['localhost'].includes(hostname) || /(\.local|\.lan)$/i.test(hostname)) {
return false;
}
Expand Down Expand Up @@ -8848,6 +8856,7 @@ init()
maxBodySize: MAX_BODY_SIZE,
version: packageData.version
});

parentPort.postMessage({ cmd: 'ready' });
})
.catch(err => {
Expand Down

0 comments on commit e947a0b

Please sign in to comment.