Skip to content

Commit 3eb860d

Browse files
dedo1911sindresorhus
authored andcommitted
Fix Electron 5 compatibility (#10)
1 parent 85b8813 commit 3eb860d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const getPath = async pth => {
1818
if (result.isDirectory()) {
1919
return getPath(path.join(pth, 'index.html'));
2020
}
21-
} catch (err) {}
21+
} catch (error) {}
2222
};
2323

2424
module.exports = options => {
@@ -42,7 +42,15 @@ module.exports = options => {
4242
});
4343
};
4444

45-
electron.protocol.registerStandardSchemes([options.scheme], {secure: true});
45+
if (electron.protocol.registerStandardSchemes) {
46+
// Electron <= 4.x
47+
electron.protocol.registerStandardSchemes([options.scheme], {secure: true});
48+
} else {
49+
// Electron >= 5.x
50+
electron.protocol.registerSchemesAsPrivileged([
51+
{scheme: options.scheme, privileges: {secure: true, standard: true}}
52+
]);
53+
}
4654

4755
electron.app.on('ready', () => {
4856
const session = options.partition ?

0 commit comments

Comments
 (0)