(re: RegExp)
| 11 | */ |
| 12 | |
| 13 | function testUserAgent(re: RegExp) { |
| 14 | if (typeof window === 'undefined' || window.navigator == null) { |
| 15 | return false; |
| 16 | } |
| 17 | let brands = window.navigator['userAgentData']?.brands; |
| 18 | return ( |
| 19 | (Array.isArray(brands) && |
| 20 | brands.some((brand: {brand: string; version: string}) => re.test(brand.brand))) || |
| 21 | re.test(window.navigator.userAgent) |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | function testPlatform(re: RegExp) { |
| 26 | return typeof window !== 'undefined' && window.navigator != null |