Skip to content

Commit

Permalink
Backport - Improve detection: recognize Samsung Galaxy Watch devices …
Browse files Browse the repository at this point in the history
…as `wearable`

(cherry picked from commit ccc5542)
  • Loading branch information
faisalman committed Sep 10, 2024
1 parent b6a92c6 commit a77184f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@
// Samsung
/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
], [MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]], [
/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
/samsung[- ]([-\w]+)/i,
/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
/samsung[- ]((?!sm-[lr])[-\w]+)/i,
/sec-(sgh\w+)/i
], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [

Expand Down Expand Up @@ -686,6 +686,8 @@
// WEARABLES
///////////////////

/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i // Samsung Galaxy Watch
], [MODEL, [VENDOR, SAMSUNG], [TYPE, WEARABLE]], [
/((pebble))app/i // Pebble
], [VENDOR, MODEL, [TYPE, WEARABLE]], [
/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i // Apple Watch
Expand Down
36 changes: 36 additions & 0 deletions test/device-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,42 @@
"type": "tablet"
}
},
{
"desc": "Samsung Galaxy Watch",
"ua": "Mozilla/5.0 (Linux; Tizen 5.5; SAMSUNG SM-R805W) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.0 Chrome/69.0.3497.106 Mobile Safari/537.36",
"expect": {
"vendor": "Samsung",
"model": "SM-R805W",
"type": "wearable"
}
},
{
"desc": "Samsung Galaxy Watch Active 2",
"ua": "Mozilla/5.0 (Linux; Tizen 5.5; SAMSUNG SM-R820) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.0 Chrome/69.0.3497.106 Mobile Safari/537.36",
"expect": {
"vendor": "Samsung",
"model": "SM-R820",
"type": "wearable"
}
},
{
"desc": "Samsung Galaxy Watch4",
"ua": "Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-R875U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.2. Chrome/102.0.5005.125 Mobile Safari/537.36",
"expect": {
"vendor": "Samsung",
"model": "SM-R875U",
"type": "wearable"
}
},
{
"desc": "Samsung Galaxy Watch5 Pro",
"ua": "Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-R925U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.2. Chrome/111.0.5563.116 Mobile Safari/537.36",
"expect": {
"vendor": "Samsung",
"model": "SM-R925U",
"type": "wearable"
}
},
{
"desc": "Samsung Note 10.1",
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; SM-P605) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36",
Expand Down

0 comments on commit a77184f

Please sign in to comment.