-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Fix platform detection after Node.js 21 #200935
Conversation
Node.js 21 added `navigator.userAgent`, which breaks the previous detection.
The same problem happen in |
_language = _locale; | ||
_platformLocale = navigator.language; | ||
} | ||
|
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.
Only reorder two code block, without change the block content.
@@ -75,31 +75,8 @@ interface INavigator { | |||
} | |||
declare const navigator: INavigator; | |||
|
|||
// Web environment | |||
if (typeof navigator === 'object' && !isElectronRenderer) { |
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.
Previous detection expect that Node.js doesn't have navigator
, now Node.js 21 had, with navigator.userAgent === 'Node.js/21'
.
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.
LGTM, thanks!
/cc @bpasero for another set of 👀
Node.js 21 added
navigator.userAgent
, which breaks the previous detection.Close #200934