Skip to content

Commit dfdb167

Browse files
authored
check if brands is an array before using .some (#8458)
1 parent e474edb commit dfdb167

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/@react-aria/utils/src/platform.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ function testUserAgent(re: RegExp) {
1414
if (typeof window === 'undefined' || window.navigator == null) {
1515
return false;
1616
}
17-
return (
18-
window.navigator['userAgentData']?.brands.some((brand: {brand: string, version: string}) => re.test(brand.brand))
19-
) ||
20-
re.test(window.navigator.userAgent);
17+
let brands = window.navigator['userAgentData']?.brands;
18+
return Array.isArray(brands) && brands.some((brand: {brand: string, version: string}) => re.test(brand.brand)) ||
19+
re.test(window.navigator.userAgent);
2120
}
2221

2322
function testPlatform(re: RegExp) {

0 commit comments

Comments
 (0)