Skip to content

Commit

Permalink
detect-browser
Browse files Browse the repository at this point in the history
  • Loading branch information
clemiller committed Jul 24, 2024
1 parent 0dd327d commit a8c9105
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions nav-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nav-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"core-js": "^3.31.1",
"d3": "^7.8.5",
"d3-svg-legend": "^2.25.6",
"detect-browser": "^5.3.0",
"file-saver": "^2.0.5",
"load-json-file": "^7.0.1",
"mathjs": "^12.4.2",
Expand Down
12 changes: 6 additions & 6 deletions nav-app/src/app/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// utils.ts
import { detect } from "detect-browser";

let comparatorFn = {
'<': function(a, b) { return a < b; },
'<=': function(a, b) { return a <= b; },
Expand All @@ -15,9 +17,8 @@ export function isNumber(value: any): boolean {
}

export function isIE(): boolean {
let userAgent = (window.navigator && window.navigator.userAgent || '').toLowerCase();
let match = userAgent.match(/(?:msie |trident.+?; rv:)(\d+)/);
return match !== null;
const browser = detect();
return browser.name == 'ie';
}

export function isSafari(compRange): boolean {
Expand All @@ -28,7 +29,6 @@ export function isSafari(compRange): boolean {
return comparatorFn[op] ? comparatorFn[op](version, n) : (version == n || n !== n);
}

let userAgent = (window.navigator && window.navigator.userAgent || '').toLowerCase();
var match = userAgent.match(/version\/(\d+).+?safari/);
return match !== null && compare(match[1], compRange);
const browser = detect();
return browser.name == 'safari' && compare(browser.version.split('.')[0], compRange);
}

0 comments on commit a8c9105

Please sign in to comment.