Skip to content

Commit a1cfca4

Browse files
committed
Fix #815 - Improve device detection: OnePlus device misidentified as LG tablet
1 parent 1816450 commit a1cfca4

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/main/ua-parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@
610610
], [[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, MOBILE]], [
611611

612612
// OnePlus
613-
/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-k]\w[1m]10)\b/i,
613+
/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-l]\w[1m]10)\b/i,
614614
/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
615615
], [MODEL, [VENDOR, ONEPLUS], [TYPE, MOBILE]], [
616616

@@ -650,7 +650,7 @@
650650
], [MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]], [
651651

652652
// LG
653-
/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
653+
/\b(?:lg)?([vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
654654
], [MODEL, [VENDOR, LG], [TYPE, TABLET]], [
655655
/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
656656
/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,

test/data/ua/device/lg.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@
188188
"type": "tablet"
189189
}
190190
},
191+
{
192+
"desc": "LG G Pad F2",
193+
"ua": "Mozilla/5.0 (Linux; Android 7.1.1; LG-LK460 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Safari/537.36",
194+
"expect": {
195+
"vendor": "LG",
196+
"model": "LK460",
197+
"type": "tablet"
198+
}
199+
},
191200
{
192201
"desc": "LG Watch Urbane",
193202
"ua": "Mozilla/5.0 Linux; Android 7.1.1; LG Watch Urbane Build/NWD1.180306.004 AppleWebKit/537.36 KHTML, like Gecko Chrome/19.77.34.5 Mobile Safari/537.36",

test/data/ua/device/oneplus.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@
170170
"type": "mobile"
171171
}
172172
},
173+
{
174+
"desc": "OnePlus 15",
175+
"ua": "Mozilla/5.0 (Linux; Android 16; PLK110 Build/BP2A.250605.015; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/134.0.6998.135 Mobile Safari/537.36",
176+
"expect": {
177+
"vendor": "OnePlus",
178+
"model": "PLK110",
179+
"type": "mobile"
180+
}
181+
},
173182
{
174183
"desc": "OnePlus Ace",
175184
"ua": "Mozilla/5.0 (Linux; U; Android 15; zh-cn; PGKM10 Build/AP3A.240617.008) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/115.0.5790.168 Mobile Safari/537.36 HeyTapBrowser/40.9.6.2",

0 commit comments

Comments
 (0)