From 20ceaf9000bdc2d641ca1ff2933ee20c851bebef Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 12 Aug 2020 11:00:50 -0700 Subject: [PATCH] Extract Chromecast firmware version Rather than put the CPU type as the OS version, for Chromecast, the firmware version would be much more useful. For example: Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.81 Safari/537.36 CrKey/1.42.183786 This should produce: os: { name: "Chromecast", version: "1.42.183786" } Instead of: os: { name: "Linux", version: "aarch64" } --- src/ua-parser.js | 4 ++++ test/os-test.json | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/ua-parser.js b/src/ua-parser.js index a9e6c53..a6033bb 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -731,6 +731,10 @@ /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS ], [[NAME, 'Firefox OS'], VERSION], [ + // Google Chromecast + /crkey\/([\d\.]+)/i // Google Chromecast + ], [VERSION, [NAME, 'Chromecast']], [ + // Console /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation diff --git a/test/os-test.json b/test/os-test.json index b944ac0..ab973c0 100644 --- a/test/os-test.json +++ b/test/os-test.json @@ -251,6 +251,15 @@ "version" : "undefined" } }, + { + "desc" : "Google Chromecast", + "ua" : "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.81 Safari/537.36 CrKey/1.42.183786", + "expect" : + { + "name" : "Chromecast", + "version" : "1.42.183786" + } + }, { "desc" : "Nintendo", "ua" : "",