Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/lib/share/feature.ts
1450 views
1
/* NOTE: There is similar (but currently insanely convoluted)
2
functionality in @cocalc/frontend/feature.ts.
3
*/
4
5
declare var window;
6
export function isIOS(): boolean {
7
if (typeof window == "undefined") return false;
8
const { navigator } = window;
9
return (
10
navigator?.userAgent?.match(/Mac/) &&
11
navigator.maxTouchPoints &&
12
navigator.maxTouchPoints > 2
13
);
14
}
15
16
export function isSafari(): boolean {
17
if (typeof window == "undefined") return false;
18
if (isChrome()) return false;
19
const { navigator } = window;
20
return navigator?.userAgent?.match(/Safari/);
21
}
22
23
export function isChrome(): boolean {
24
if (typeof window == "undefined") return false;
25
const { navigator } = window;
26
return /Chrom(e|ium)/.test(navigator?.userAgent ?? "");
27
}
28
29