Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: added isBroswer check to isWindows and isChromiumBased function #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/helpers/browsers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isRunningOnClientSide } from './is-running-on-client-side';
import { isRunningOnClientSide } from "./is-running-on-client-side";

export function isFF(): boolean {
if (!isRunningOnClientSide) {
return false;
}
return window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
return window.navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
}

export function isIOS(): boolean {
Expand All @@ -24,21 +24,25 @@ export function isChrome(): boolean {

// Determine whether the browser is running on windows.
export function isWindows(): boolean {
if (!isRunningOnClientSide) {
return false;
}
// more accurate if available
if (
navigator?.userAgentData?.platform
) {
return navigator.userAgentData.platform === 'Windows';
if (navigator?.userAgentData?.platform) {
return navigator.userAgentData.platform === "Windows";
}
return navigator.userAgent.toLowerCase().indexOf('win') >= 0;
return navigator.userAgent.toLowerCase().indexOf("win") >= 0;
}

// Determine whether the browser is Chromium based.
export function isChromiumBased(): boolean {
if (!navigator.userAgentData) { return false; }
return navigator.userAgentData.brands.some(
(brand: UADataBrand) => {
return brand.brand.includes('Chromium');
}
);
if (!isRunningOnClientSide) {
return false;
}
if (!navigator.userAgentData) {
return false;
}
return navigator.userAgentData.brands.some((brand: UADataBrand) => {
return brand.brand.includes("Chromium");
});
}