Skip to content

Commit 1c16061

Browse files
committed
Node robustness
1 parent 23e8c63 commit 1c16061

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/text-annotator-react/src/TextAnnotationPopup/isMobile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// https://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system
22
export const isMobile = () => {
3+
if (typeof navigator === 'undefined') return false;
4+
35
// @ts-ignore
4-
var userAgent: string = navigator?.userAgent || navigator?.vendor || window?.opera;
6+
var userAgent: string = navigator.userAgent || navigator.vendor || window?.opera;
57

68
if (/android/i.test(userAgent))
79
return true;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
// @ts-ignore
2-
export const isMac = /mac/i.test(navigator?.userAgentData ? navigator.userAgentData.platform : navigator?.platform);
1+
export const isMac = typeof navigator !== 'undefined' &&
2+
// @ts-ignore
3+
/mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform);

0 commit comments

Comments
 (0)