blob: 413a6050047e9238d78553e8984494853dcdcd72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
const browserMap = {
chrome: "Chrome",
edge: "Edge",
firefox: "Firefox",
ie: "IE",
jsdom: "JSDOM",
opera: "Opera",
safari: "Safari"
};
export function browserSupportsHeadless( browser ) {
browser = browser.toLowerCase();
return (
browser === "chrome" ||
browser === "firefox" ||
browser === "edge"
);
}
export function getBrowserString(
{
browser,
browser_version: browserVersion,
device,
os,
os_version: osVersion
},
headless
) {
browser = browser.toLowerCase();
browser = browserMap[ browser ] || browser;
let str = browser;
if ( browserVersion ) {
str += ` ${ browserVersion }`;
}
if ( device ) {
str += ` for ${ device }`;
}
if ( os ) {
str += ` on ${ os }`;
}
if ( osVersion ) {
str += ` ${ osVersion }`;
}
if ( headless && browserSupportsHeadless( browser ) ) {
str += " (headless)";
}
return str;
}
|