From 8d3c2d327cf540ff2c050f1cc67bca8c6f8e4458 Mon Sep 17 00:00:00 2001 From: Oscar Becerra Date: Mon, 17 Oct 2022 14:03:53 -0700 Subject: [PATCH 1/3] Add new browser: Cobalt --- src/ua-parser.js | 5 ++++- test/browser-test.json | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index b47ad23..e2c3263 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -330,7 +330,10 @@ /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i, // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser /(links) \(([\w\.]+)/i // Links - ], [NAME, VERSION] + ], [NAME, VERSION], [ + + /(cobalt)\/([\w\.]+)/i // Cobalt + ], [NAME, [VERSION, /master.|lts./, ""]] ], cpu : [[ diff --git a/test/browser-test.json b/test/browser-test.json index bf8163a..2be58c2 100644 --- a/test/browser-test.json +++ b/test/browser-test.json @@ -1591,5 +1591,41 @@ "version" : "15.6,2", "major" : "15" } + }, + { + "desc" : "Cobalt 23 Master", + "ua" : "Mozilla/5.0 (X11; Linux x86_64) Cobalt/23.master.0.0-devel (unlike Gecko) v8/8.8.278.8-jit gles Starboard/15", + "expect" : { + "name" : "Cobalt", + "version": "23.0.0", + "major" : "23" + } + }, + { + "desc" : "Cobalt 23 LTS", + "ua" : "Mozilla/5.0 (X11; Linux x86_64) Cobalt/23.lts.1.0-qa (unlike Gecko) v8/8.8.278.8-jit gles Starboard/15", + "expect" : { + "name" : "Cobalt", + "version": "23.1.0", + "major" : "23" + } + }, + { + "desc" : "Cobalt 11", + "ua" : "Mozilla/5.0 (X11; Linux x86_64) Cobalt/11.0-qa (unlike Gecko) Starboard/6", + "expect" : { + "name" : "Cobalt", + "version": "11.0", + "major" : "11" + } + }, + { + "desc" : "Cobalt 9", + "ua" : "Mozilla/5.0 (X11; Linux x86_64) Cobalt/9.0-qa (unlike Gecko) Starboard/4", + "expect" : { + "name" : "Cobalt", + "version": "9.0", + "major" : "9" + } } ] From 7f71024161399b7aa5d5cd10dba9e059f0218262 Mon Sep 17 00:00:00 2001 From: Riley Shaw Date: Wed, 26 Oct 2022 13:17:33 -0400 Subject: [PATCH 2/3] Fix documentation `readme.md` refers to a `parser.getResults` function, which does not exist. This PR corrects the function name to `getResult`. --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 185a2f9..71bb187 100644 --- a/readme.md +++ b/readme.md @@ -36,7 +36,7 @@ Like so: ```js let parser = new UAParser("user-agent"); // you need to pass the user-agent for nodejs console.log(parser); // {} -let parserResults = parser.getResults(); +let parserResults = parser.getResult(); console.log(parserResults); /** { "ua": "", @@ -48,7 +48,7 @@ console.log(parserResults); } */ ``` -When you call UAParser without the `new` keyword, it will automatically call `getResults()` function and return the parsed results. +When you call UAParser without the `new` keyword, it will automatically call `getResult()` function and return the parsed results. * `UAParser([uastring][,extensions])` * returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }` From a88660493568d6144a551424a8139d6c876635f6 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Tue, 6 Dec 2022 09:53:54 +0700 Subject: [PATCH 3/3] Fix #605 - Identify Macintosh as Apple device --- src/ua-parser.js | 2 ++ test/device-test.json | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/ua-parser.js b/src/ua-parser.js index e2c3263..b050833 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -390,6 +390,8 @@ /applecoremedia\/[\w\.]+ \((ipad)/i, /\b(ipad)\d\d?,\d\d?[;\]].+ios/i ], [MODEL, [VENDOR, APPLE], [TYPE, TABLET]], [ + /(macintosh);/i + ], [MODEL, [VENDOR, APPLE]], [ // Huawei /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i diff --git a/test/device-test.json b/test/device-test.json index bad1e50..33bfd17 100644 --- a/test/device-test.json +++ b/test/device-test.json @@ -754,6 +754,15 @@ "type": "mobile" } }, + { + "desc": "Apple Desktop", + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15", + "expect": { + "vendor": "Apple", + "model": "Macintosh", + "type": "undefined" + } + }, { "desc": "iPad using UCBrowser", "ua": "Mozilla/5.0 (iPad; U; CPU OS 11_2 like Mac OS X; zh-CN; iPad5,3) AppleWebKit/534.46 (KHTML, like Gecko) UCBrowser/3.0.1.776 U3/ Mobile/10A403 Safari/7543.48.3",