Skip to content

Commit

Permalink
fix: host must be a valid HTTPS URL when using ElectronPublicUpdateSe…
Browse files Browse the repository at this point in the history
…rvice (#174)

* test: Add test for only give update type electron and repo but no host

* fix: Set a default host is used without specifying a host

Only happened when using 'ElectronPublicUpdateService'
  • Loading branch information
rhy3h authored Jan 30, 2025
1 parent 691ad17 commit 3eee2b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ function validateInput(opts: IUpdateElectronAppOptions) {
'repo is required and should be in the format `owner/repo`',
);

if (!updateSource.host) {
updateSource.host = host;
}

assert(updateSource.host && isHttpsUrl(updateSource.host), 'host must be a valid HTTPS URL');
break;
}
Expand Down
17 changes: 16 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import path from 'node:path';

import { autoUpdater, dialog } from 'electron';

import { updateElectronApp, makeUserNotifier, IUpdateInfo, IUpdateDialogStrings } from '../src';
import {
updateElectronApp,
makeUserNotifier,
IUpdateInfo,
IUpdateDialogStrings,
UpdateSourceType,
} from '../src';
const repo = 'some-owner/some-repo';

beforeEach(() => {
Expand Down Expand Up @@ -49,6 +55,15 @@ describe('updateElectronApp', () => {
updateElectronApp({ repo, host: 'http://example.com' });
}).toThrow('host must be a valid HTTPS URL');
});

it('from default', () => {
updateElectronApp({
updateSource: {
type: UpdateSourceType.ElectronPublicUpdateService,
repo,
},
});
});
});

describe('updateInterval', () => {
Expand Down

0 comments on commit 3eee2b0

Please sign in to comment.