]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor: fix tests
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 25 Jun 2021 16:43:26 +0000 (18:43 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 25 Jun 2021 16:43:26 +0000 (18:43 +0200)
src/devtools/file-saver.ts

index 1699705423af0e0e19c1f82b0e4aa130c956e2a7..7731d72533baf6c149b5ca48b6bb1fdebff97d1d 100644 (file)
@@ -90,13 +90,16 @@ function click(node: Element) {
   }
 }
 
+const _navigator =
+  /*#__PURE__*/ typeof navigator === 'object' ? navigator : { userAgent: '' }
+
 // Detect WebView inside a native macOS app by ruling out all browsers
 // We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
 // https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
 const isMacOSWebView = /*#__PURE__*/ (() =>
-  /Macintosh/.test(navigator.userAgent) &&
-  /AppleWebKit/.test(navigator.userAgent) &&
-  !/Safari/.test(navigator.userAgent))()
+  /Macintosh/.test(_navigator.userAgent) &&
+  /AppleWebKit/.test(_navigator.userAgent) &&
+  !/Safari/.test(_navigator.userAgent))()
 
 export type SaveAs =
   | ((blob: Blob, name?: string, opts?: Options) => void)
@@ -113,7 +116,7 @@ export const saveAs: SaveAs = !IS_CLIENT
   'download' in HTMLAnchorElement.prototype && !isMacOSWebView
   ? downloadSaveAs
   : // Use msSaveOrOpenBlob as a second approach
-  'msSaveOrOpenBlob' in navigator
+  'msSaveOrOpenBlob' in _navigator
   ? msSaveAs
   : // Fallback to using FileReader and a popup
     fileSaverSaveAs