Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Jan 28, 2023
2 parents cf09322 + f815ca6 commit c9d1ab9
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 44 deletions.
36 changes: 18 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ The methods are self explanatory, here's a small overview on all the available m
# Possible 'browser.name':
2345Explorer, 360 Browser, Amaya, Android Browser, Arora, Avant, Avast, AVG,
BIDUBrowser, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
Chrome Headless, Chrome WebView, Chrome, Chromium, Comodo Dragon, Dillo,
Chrome Headless, Chrome WebView, Chrome, Chromium, Cobalt, Comodo Dragon, Dillo,
Dolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon, Fennec,
Firebird, Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, Huawei Browser,
ICE Browser, IE, IEMobile, IceApe, IceCat, IceDragon, Iceweasel, Instagram,
Iridium, Iron, Jasmine, K-Meleon, Kindle, Klar, Konqueror, LBBROWSER, Line,
LinkedIn, Links, Lunascape, Lynx, MIUI Browser, Maemo Browser, Maemo, Maxthon,
MetaSr Midori, Minimo, Mobile Safari, Mosaic, Mozilla, NetFront, NetSurf, Netfront,
Netscape, NokiaBrowser, Obigo, Oculus Browser, OmniWeb, Opera Coast,
Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Polaris, Puffin, QQ,
QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari, Sailfish Browser,
Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim, SlimBrowser, Swiftfox,
Tesla, Tizen Browser, UCBrowser, UP.Browser, Vivaldi, Waterfox, WeChat, Weibo,
Yandex, baidu, iCab, w3m, Whale Browser...
Iridium, Iron, Jasmine, Kakao[Story/Talk], K-Meleon, Kindle, Klar, Konqueror,
LBBROWSER, Line, LinkedIn, Links, Lunascape, Lynx, MIUI Browser, Maemo Browser,
Maemo, Maxthon, MetaSr Midori, Minimo, Mobile Safari, Mosaic, Mozilla, NetFront,
NetSurf, Netfront, Netscape, NokiaBrowser, Obigo, Oculus Browser, OmniWeb,
Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Polaris,
Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari,
Sailfish Browser, Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim,
SlimBrowser, Swiftfox, Tesla, Tizen Browser, UCBrowser, UP.Browser, Viera,
Vivaldi, Waterfox, WeChat, Weibo, Yandex, baidu, iCab, w3m, Whale Browser...

# 'browser.version' determined dynamically
```
Expand All @@ -113,10 +113,10 @@ console, mobile, tablet, smarttv, wearable, embedded

# Possible 'device.vendor':
Acer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
Essential, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla, Lenovo, LG,
Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus, OPPO, Ouya,
Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp, Siemens,
Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
Essential, Facebook, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla, Kobo,
Lenovo, LG, Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus,
OPPO, Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp,
Siemens, Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...

# 'device.model' determined dynamically
```
Expand All @@ -141,10 +141,10 @@ AIX, Amiga OS, Android[-x86], Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
Contiki, Fedora, Firefox OS, FreeBSD, Debian, Deepin, DragonFly, elementary OS,
Fuchsia, Gentoo, GhostBSD, GNU, Haiku, HarmonyOS, HP-UX, Hurd, iOS, Joli, KaiOS,
Linpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix,
Mint, Morph OS, NetBSD, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PC-BSD, PCLinuxOS,
Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, RISC OS, Sabayon,
Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu, Unix,
VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk, ...
Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenVMS, OS/2, Palm,
PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS,
RISC OS, Sabayon, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
Ubuntu, Unix, VectorLinux, Viera, WebOS, Windows [Phone/Mobile], Zenwalk, ...

# 'os.version' determined dynamically
```
Expand Down
69 changes: 44 additions & 25 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
SAMSUNG = 'Samsung',
SHARP = 'Sharp',
SONY = 'Sony',
VIERA = 'Viera',
XIAOMI = 'Xiaomi',
ZEBRA = 'Zebra',
FACEBOOK = 'Facebook';
Expand Down Expand Up @@ -116,6 +117,7 @@
// try matching uastring with regexes
while (j < regex.length && !matches) {

if (!regex[j]) { break; }
matches = regex[j++].exec(ua);

if (!!matches) {
Expand Down Expand Up @@ -232,7 +234,7 @@
/(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer

// Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
// Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ, aka ShouQ
/(weibo)__([\d\.]+)/i // Weibo
], [NAME, VERSION], [
Expand Down Expand Up @@ -283,6 +285,8 @@
// WebView
/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
], [[NAME, FACEBOOK], VERSION], [
/(kakao(?:talk|story))[\/ ]([\w\.]+)/i, // Kakao App
/(naver)\(.*?(\d+\.[\w\.]+).*\)/i, // Naver InApp
/safari (line)\/([\w\.]+)/i, // Line App for iOS
/\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
/(chromium|instagram)[\/ ]([-\w\.]+)/i // Chromium/Instagram
Expand Down Expand Up @@ -329,7 +333,8 @@
// Other
/(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
/(links) \(([\w\.]+)/i, // Links
/panasonic;(viera)/i // Panasonic Viera
], [NAME, VERSION], [

/(cobalt)\/([\w\.]+)/i // Cobalt
Expand Down Expand Up @@ -372,13 +377,12 @@

//////////////////////////
// MOBILES & TABLETS
// Ordered by popularity
/////////////////////////

// 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+|galaxy nexus)/i,
/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
/samsung[- ]([-\w]+)/i,
/sec-(sgh\w+)/i
], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
Expand All @@ -393,6 +397,10 @@
/(macintosh);/i
], [MODEL, [VENDOR, APPLE]], [

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

// Huawei
/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
Expand Down Expand Up @@ -496,7 +504,7 @@

// ZTE
/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [

// Acer
Expand All @@ -508,10 +516,6 @@
/\bmz-([-\w]{2,})/i
], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [

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

// MIXED
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,
// BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
Expand All @@ -523,6 +527,7 @@
/(oppo) ?([\w ]+) bui/i // OPPO
], [VENDOR, MODEL, [TYPE, MOBILE]], [

/(kobo)\s(ereader|touch)/i, // Kobo
/(archos) (gamepad2?)/i, // Archos
/(hp).+(touchpad(?!.+tablet)|tablet)/i, // HP TouchPad
/(kindle)\/([\w\.]+)/i, // Kindle
Expand Down Expand Up @@ -592,20 +597,6 @@
/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
], [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]], [

///////////////////
// CONSOLES
///////////////////

/(ouya)/i, // Ouya
/(nintendo) ([wids3utch]+)/i // Nintendo
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
/droid.+; (shield) bui/i // Nvidia
], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
/(playstation [345portablevi]+)/i // Playstation
], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
/\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [

///////////////////
// SMARTTVS
///////////////////
Expand All @@ -629,12 +620,28 @@
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
/(mitv-\w{5}) bui/i // Xiaomi
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
/Hbbtv.*(technisat) (.*);/i // TechniSAT
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i // HbbTV devices
/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
], [[TYPE, SMARTTV]], [

///////////////////
// CONSOLES
///////////////////

/(ouya)/i, // Ouya
/(nintendo) ([wids3utch]+)/i // Nintendo
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
/droid.+; (shield) bui/i // Nvidia
], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
/(playstation [345portablevi]+)/i // Playstation
], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
/\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [

///////////////////
// WEARABLES
///////////////////
Expand All @@ -645,7 +652,7 @@
], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [
/droid.+; (wt63?0{2,3})\)/i
], [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]], [
/(quest( 2)?)/i // Oculus Quest
/(quest( 2| pro)?)/i // Oculus Quest
], [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]], [

///////////////////
Expand Down Expand Up @@ -734,6 +741,11 @@
/(cros) [\w]+ ([\w\.]+\w)/i // Chromium OS
], [[NAME, 'Chromium OS'], VERSION],[

// Smart TVs
/panasonic;(viera)/i, // Panasonic Viera
/(netrange)mmh/i, // Netrange
/(nettv)\/(\d+\.[\w\.]+)/i, // NetTV

// Console
/(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
/(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
Expand Down Expand Up @@ -775,6 +787,7 @@
}

var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
var _uach = (typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgentData) ? window.navigator.userAgentData : undefined;
var _rgxmap = extensions ? extend(regexes, extensions) : regexes;

this.getBrowser = function () {
Expand All @@ -797,6 +810,9 @@
_device[MODEL] = undefined;
_device[TYPE] = undefined;
rgxMapper.call(_device, _ua, _rgxmap.device);
if (!_device[TYPE] && _uach && _uach.mobile) {
_device[TYPE] = MOBILE;
}
return _device;
};
this.getEngine = function () {
Expand All @@ -811,6 +827,9 @@
_os[NAME] = undefined;
_os[VERSION] = undefined;
rgxMapper.call(_os, _ua, _rgxmap.os);
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
_os[NAME] = _uach.platform.replace(/chrome/i, 'Chromium').replace(/mac/i, 'Mac ');
}
return _os;
};
this.getResult = function () {
Expand Down
55 changes: 55 additions & 0 deletions test/browser-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,16 @@
"major" : "1"
}
},
{
"desc" : "Viera",
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
"expect" :
{
"name" : "VIERA",
"version" : "undefined",
"major" : "undefined"
}
},
{
"desc" : "Yandex",
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.5 (KHTML, like Gecko) YaBrowser/1.0.1084.5402 Chrome/19.0.1084.5402 Safari/536.5",
Expand Down Expand Up @@ -1627,5 +1637,50 @@
"version": "9.0",
"major" : "9"
}
},
{
"desc" : "KakaoTalk App Android",
"ua" : "Mozilla/5.0 (Linux; Android 12; SM-G988N Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/100.0.4896.79 Mobile Safari/537.36;KAKAOTALK 2409760",
"expect" : {
"name" : "KAKAOTALK",
"version": "2409760",
"major" : "2409760"
}
},
{
"desc" : "KakaoStory App Android",
"ua" : "Mozilla/5.0 (Linux; Android 12; SM-G988N Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/100.0.4896.79 Mobile Safari/537.36 KAKAOSTORY/6.8.3_21046",
"expect" : {
"name" : "KAKAOSTORY",
"version": "6.8.3_21046",
"major" : "6"
}
},
{
"desc" : "KakaoTalk App iOS",
"ua" : "Mozilla/5.0 (iPhone; CPU; iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 BizWebView KAKAOTALK 9.7.6",
"expect" : {
"name" : "KAKAOTALK",
"version": "9.7.6",
"major" : "9"
}
},
{
"desc" : "Naver App Android",
"ua" : "Mozilla/5.0 (Linux; Android 12; SM-G988N Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/90.0.4430.232 Whale/1.0.0.0 Crosswalk/26.90.3.21 Mobile Safari/537.36 NAVER(inapp; search; 1010; 11.11.2)",
"expect" : {
"name" : "NAVER",
"version": "11.11.2",
"major" : "11"
}
},
{
"desc" : "Naver App iOS",
"ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/605.1 NAVER(inapp; search; 720; 10.25.0; 11PRO)",
"expect" : {
"name" : "NAVER",
"version": "10.25.0",
"major" : "10"
}
}
]
Loading

0 comments on commit c9d1ab9

Please sign in to comment.