Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Sep 18, 2022
2 parents 896bdd0 + 8483ac0 commit d141915
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: ua-parser-js-run-test

on: [push, pull_request]

permissions:
contents: read

jobs:
run-test:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@
"Zach Bjornson <zbbjornson@gmail.com>"
],
"main": "src/ua-parser.js",
"files": [
"dist",
"src"
],
"scripts": {
"build": "uglifyjs src/ua-parser.js -o dist/ua-parser.min.js --comments '/^ UA/' && uglifyjs src/ua-parser.js -o dist/ua-parser.pack.js --comments '/^ UA/' --compress --mangle",
"test": "jshint src/ua-parser.js && mocha -R nyan test/test.js",
Expand Down
14 changes: 8 additions & 6 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
MOTOROLA = 'Motorola',
OPERA = 'Opera',
SAMSUNG = 'Samsung',
SHARP = 'Sharp',
SONY = 'Sony',
XIAOMI = 'Xiaomi',
ZEBRA = 'Zebra',
Expand Down Expand Up @@ -301,9 +302,9 @@
/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i // Chrome/OmniWeb/Arora/Tizen/Nokia
], [NAME, VERSION], [

/version\/([\w\.]+) .*mobile\/\w+ (safari)/i // Mobile Safari
/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i // Mobile Safari
], [VERSION, [NAME, 'Mobile Safari']], [
/version\/([\w\.]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
], [VERSION, NAME], [
/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
], [NAME, [VERSION, strMapper, oldSafariMap]], [
Expand Down Expand Up @@ -504,7 +505,7 @@

// Sharp
/\b(sh-?[altvz]?\d\d[a-ekm]?)/i
], [MODEL, [VENDOR, 'Sharp'], [TYPE, MOBILE]], [
], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [

// MIXED
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,
Expand Down Expand Up @@ -616,9 +617,10 @@
], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/droid.+aft(\w)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i // Sharp
], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [
/(bravia[\w- ]+) bui/i // Sony
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
/(bravia[\w ]+)( bui|\))/i // Sony
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
/(mitv-\w{5}) bui/i // Xiaomi
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
Expand Down
20 changes: 20 additions & 0 deletions test/browser-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,5 +1571,25 @@
{
"name" : "LinkedIn"
}
},
{
"desc" : "Safari including comma in minor version number",
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6,2 Safari/605.1.15",
"expect" :
{
"name" : "Safari",
"version" : "15.6,2",
"major" : "15"
}
},
{
"desc" : "Mobile Safari including comma in minor version number",
"ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6,2 Mobile/15E148 Safari/604.1",
"expect" :
{
"name" : "Mobile Safari",
"version" : "15.6,2",
"major" : "15"
}
}
]
27 changes: 27 additions & 0 deletions test/device-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,15 @@
"type": "smarttv"
}
},
{
"desc": "Sharp AQUOS-TVX19B",
"ua": "Mozilla/5.0 (Linux; Android 9; AQUOS-TVX19B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36",
"expect": {
"vendor": "Sharp",
"model": "AQUOS-TVX19B",
"type": "smarttv"
}
},
{
"desc": "Sharp Aquos B10",
"ua": "Mozilla/5.0 (Linux; Android 7.0; SH-A01) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Mobile Safari/537.36",
Expand Down Expand Up @@ -1890,6 +1899,24 @@
"type": "smarttv"
}
},
{
"desc": "Sony BRAVIA 4K GB ATV3",
"ua": "Mozilla/5.0 (Linux; Android 9; BRAVIA 4K GB ATV3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36",
"expect": {
"vendor": "Sony",
"model": "BRAVIA 4K GB ATV3",
"type": "smarttv"
}
},
{
"desc": "Sony Bravia 4k UR2",
"ua": "Mozilla/5.0 (Linux: Andr0id 9: BRAVIA 4K UR2 Build/PTT1.190515.001.S104) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36 OPR/46.0.2207.0 OMI/4.13.5.431.DIA5HBBTV.250 Model/Sony-BRAVIA-4K-UR2",
"expect": {
"vendor": "Sony",
"model": "BRAVIA 4K UR2",
"type": "smarttv"
}
},
{
"desc" : "Tesla",
"ua" : "Mozilla/5.0 (X11; GNU/Linux) AppleWebKit/601.1 (KHTML, like Gecko) Tesla QtCarBrowser Safari/601.1",
Expand Down

0 comments on commit d141915

Please sign in to comment.