You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
493 B
20 lines
493 B
// @flow
|
|
type Navigator = Navigator & { userAgentData?: NavigatorUAData };
|
|
|
|
interface NavigatorUAData {
|
|
brands: Array<{ brand: string, version: string }>;
|
|
mobile: boolean;
|
|
platform: string;
|
|
}
|
|
|
|
export default function getUAString(): string {
|
|
const uaData = (navigator: Navigator).userAgentData;
|
|
|
|
if (uaData?.brands && Array.isArray(uaData.brands)) {
|
|
return uaData.brands
|
|
.map((item) => `${item.brand}/${item.version}`)
|
|
.join(' ');
|
|
}
|
|
|
|
return navigator.userAgent;
|
|
}
|