Skip to content

Commit b5751bb

Browse files
Make the isBrowser check aware of edge case with electron built apps
They will be marked as browsers because of global.window, erroneously.
1 parent 470f9ca commit b5751bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

api/WebApi.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ import os = require('os');
4242
import url = require('url');
4343
import path = require('path');
4444

45-
const isBrowser: boolean = typeof window !== 'undefined';
45+
const isElectron: boolean = process && process.versions && process.versions.hasOwnProperty('electron');
46+
const isElectronWebpage: boolean = isElectron && process.type === 'renderer';
47+
const isBrowser: boolean = typeof window !== 'undefined' && (!isElectron || isElectronWebpage);
48+
4649
/**
4750
* Methods to return handler objects (see handlers folder)
4851
*/

0 commit comments

Comments
 (0)