Skip to content

Commit 20e8740

Browse files
committed
Improve device detection for unknown VR device
1 parent 852520f commit 20e8740

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: src/main/ua-parser.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,8 @@
856856
// MIXED (GENERIC)
857857
///////////////////
858858

859-
/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i // Android Phones from Unidentified Vendors
860-
], [MODEL, [TYPE, MOBILE]], [
861-
/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i // Android Tablets from Unidentified Vendors
862-
], [MODEL, [TYPE, TABLET]], [
859+
/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i
860+
], [MODEL, [TYPE, strMapper, { 'mobile' : 'Mobile', 'xr' : 'VR', '*' : TABLET }]], [
863861
/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i // Unidentifiable Tablet
864862
], [[TYPE, TABLET]], [
865863
/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i // Unidentifiable Mobile

Diff for: test/data/ua/device/_others.json

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
"type": "mobile"
2525
}
2626
},
27+
{
28+
"desc": "Unknown VR Device",
29+
"ua": "Mozilla/5.0 (Linux; Android 5.0.2; Unknown Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile VR Safari/537.36",
30+
"expect": {
31+
"model": "Unknown",
32+
"type": "xr"
33+
}
34+
},
2735
{
2836
"desc": "Desktop (IE11 with Tablet string)",
2937
"ua": "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; GWX:MANAGED; rv:11.0) like Gecko",

0 commit comments

Comments
 (0)