mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Fix for modern node that includes a navigator.userAgent
This commit is contained in:
@@ -14,9 +14,9 @@ interface INavigator {
|
||||
declare const navigator: INavigator;
|
||||
declare const process: unknown;
|
||||
|
||||
// navigator is also checked here because bundling with the process module can cause issues
|
||||
// otherwise
|
||||
export const isNode = (typeof process !== 'undefined' && 'title' in (process as any) && typeof navigator === 'undefined') ? true : false;
|
||||
// navigator.userAgent is also checked here because bundling with the process module can cause
|
||||
// issues otherwise. Note that navigator exists in Node.js 21+ but the userAgent is "Node.js/<version>".
|
||||
export const isNode = (typeof process !== 'undefined' && 'title' in (process as any) && (typeof navigator === 'undefined' || navigator.userAgent.startsWith('Node.js/'))) ? true : false;
|
||||
const userAgent = (isNode) ? 'node' : navigator.userAgent;
|
||||
const platform = (isNode) ? 'node' : navigator.platform;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user