diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index ab126d2a6..203184294 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -2,6 +2,9 @@ name: ua-parser-js-run-test on: [push, pull_request] +permissions: + contents: read + jobs: run-test: runs-on: ubuntu-latest diff --git a/package.json b/package.json index d442c5765..9c673849d 100644 --- a/package.json +++ b/package.json @@ -141,6 +141,10 @@ "Zach Bjornson " ], "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", diff --git a/src/ua-parser.js b/src/ua-parser.js index 1cfded873..67e4db862 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -54,6 +54,7 @@ MOTOROLA = 'Motorola', OPERA = 'Opera', SAMSUNG = 'Samsung', + SHARP = 'Sharp', SONY = 'Sony', XIAOMI = 'Xiaomi', ZEBRA = 'Zebra', @@ -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]], [ @@ -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, @@ -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]], [ diff --git a/test/browser-test.json b/test/browser-test.json index 4895ba4d2..bf8163a1f 100644 --- a/test/browser-test.json +++ b/test/browser-test.json @@ -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" + } } ] diff --git a/test/device-test.json b/test/device-test.json index 381ace8cb..dcc0498fa 100644 --- a/test/device-test.json +++ b/test/device-test.json @@ -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", @@ -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",