From f9c6ebb6b87c2d2ed00171e6fafbc681e54d5e61 Mon Sep 17 00:00:00 2001 From: Skjalg Teig Date: Mon, 17 Oct 2022 10:36:15 +0200 Subject: [PATCH] fix(utils): Add guard for undefined navigator --- packages/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/utils.js b/packages/utils.js index d63a9b0d..381b8a97 100644 --- a/packages/utils.js +++ b/packages/utils.js @@ -1,6 +1,7 @@ export const IS_BROWSER = typeof window !== 'undefined' -export const IS_ANDROID = IS_BROWSER && /(android)/i.test(navigator.userAgent) // Bad, but needed -export const IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)) +const HAS_NAVIGATOR = IS_BROWSER && typeof window.navigator !== 'undefined' +export const IS_ANDROID = HAS_NAVIGATOR && /(android)/i.test(navigator.userAgent) // Bad, but needed +export const IS_IOS = HAS_NAVIGATOR && /iPad|iPhone|iPod/.test(String(navigator.platform)) export const IS_IE11 = IS_BROWSER && window.msCrypto // msCrypto only exists in IE11 // Mock HTMLElement for Node