flexdinesh / browser-or-node

Check where your code is running. In the browser or in node.js environment.
MIT License
245 stars 20 forks source link

[BUG] `typeof navigator !== 'undefined'`, but `navigator.userAgent` is undefined #26

Closed loynoir closed 1 year ago

loynoir commented 1 year ago

Within Deno Worker

  self.postMessage([null, typeof navigator])
  self.postMessage([null, typeof navigator.userAgent])
[ null, "object" ]
[ null, "undefined" ]

So, navigator.userAgent.includes throw error.

Related

https://github.com/flexdinesh/browser-or-node/pull/25