Skip to content

Commit a6ffe6d

Browse files
committed
fix: properly detect Chrome on iPad
1 parent 4d38b7a commit a6ffe6d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/BrowserDetector.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ export default class BrowserDetector {
191191
subString: 'Mac',
192192
identity: 'Mac OS',
193193
},
194+
{
195+
string: wnd.navigator.platform,
196+
subString: 'iPad',
197+
identity: 'iOS',
198+
},
194199
{
195200
string: wnd.navigator.userAgent,
196201
subString: 'iPhone',

test/specs/BrowserDetector.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,20 @@ describe(BrowserDetector, () => {
9696

9797
expect(detector.OS).toEqual('iOS')
9898
expect(detector.browser).toEqual('Firefox')
99-
expect(detector.version).toEqual(103)
99+
expect(detector.version).toEqual(103.1)
100+
101+
})
102+
103+
it('reports Chrome on iPad', () => {
104+
const detector = createDetector({
105+
userAgent: 'Mozilla/5.0 (iPad; CPU OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/104.0.5112.99 Mobile/15E148 Safari/604.1',
106+
platform: 'iPad',
107+
vendor: 'Apple Computer, Inc.'
108+
})
109+
110+
expect(detector.OS).toEqual('iOS')
111+
expect(detector.browser).toEqual('Chrome')
112+
expect(detector.version).toEqual(104)
100113

101114
})
102115

0 commit comments

Comments
 (0)