-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: update is-browser.ts to account undefined navigator
#1868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes electron 12.2.3, which doesn't have navigator defined mqttjs@6a03d29#commitcomment-142114121
* fix(electron): detect electron env * fix(electron): cleanup code * fix: fixed wrong operator * fix(electron): improved code and add some comments * Update src/lib/is-browser.ts Co-authored-by: Daniel Lando <[email protected]> * fix: typo and lint --------- Co-authored-by: Daniel Lando <[email protected]>
robertsLando
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you verified this is actually working on Electron?
src/lib/is-browser.ts
Outdated
| // check if we are in electron `renderer` | ||
| const electronRenderCheck = | ||
| (typeof navigator !== "undefined") && | ||
| navigator?.userAgent?.toLowerCase().indexOf(' electron/') > -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| navigator?.userAgent?.toLowerCase().indexOf(' electron/') > -1 | |
| navigator.userAgent?.toLowerCase().indexOf(' electron/') > -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robertsLando I've run npm run lint-fix and made the above changes #1868
Additionally, this has been npm run builded, npm packed, and then npm installed to my local electron 30 project and looks like it's working.
undefined navigator
|
Also pleasew fix lint issues with |
|
I am happy to verify the changes later as well! |
Fixes error
(error is thrown in electron 12.2.3 and electron 30.0.6)
6a03d29#commitcomment-142114121