Skip to content

Commit

Permalink
fix(device): Check if navigator is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
yasincaliskan committed Mar 3, 2022
1 parent 1a8b005 commit 4b76992
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hipo/react-ui-toolkit",
"version": "1.0.0-alpha.5.3.0",
"version": "1.0.0-alpha.5.3.1",
"description": "React based UI toolkit.",
"main": "dist/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/core/utils/device/deviceUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function isMobileDevice() {
const userAgent = navigator.userAgent || navigator.vendor;
const userAgent =
// eslint-disable-next-line no-negated-condition
typeof navigator !== "undefined" ? navigator.userAgent || navigator.vendor : "";
const devices = [/Android/i, /iPhone/i, /iPad/i];

return devices.some((device) => userAgent.match(device));
Expand Down
4 changes: 3 additions & 1 deletion src/core/utils/number/numberUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {FormatNumberOptions, ParseNumberOptions} from "./numberTypes";

const NAVIGATOR_LANGUAGE = typeof navigator !== "undefined" ? navigator.language : "en-GB";
const NAVIGATOR_LANGUAGE =
// eslint-disable-next-line no-negated-condition
typeof navigator !== "undefined" ? navigator.language : "en-GB";

function formatNumber(formatNumberOptions: FormatNumberOptions) {
const {locale, ...otherOptions} = formatNumberOptions;
Expand Down

0 comments on commit 4b76992

Please sign in to comment.