Skip to content

Commit

Permalink
Improve browser detection: WeChat
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Oct 23, 2023
1 parent 9cc274f commit 17f0c1e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/main/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@
/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
], [VERSION, [NAME, 'UCBrowser']], [
/microm.+\bqbcore\/([\w\.]+)/i, // WeChat Desktop for Windows Built-in Browser
/\bqbcore\/([\w\.]+).+microm/i
], [VERSION, [NAME, 'WeChat(Win) Desktop']], [
/\bqbcore\/([\w\.]+).+microm/i,
/micromessenger\/([\w\.]+)/i // WeChat
], [VERSION, [NAME, 'WeChat']], [
/konqueror\/([\w\.]+)/i // Konqueror
Expand Down Expand Up @@ -757,12 +756,12 @@
// Windows
/microsoft (windows) (vista|xp)/i // Windows (iTunes)
], [NAME, VERSION], [
/(windows) nt 6\.2; (arm)/i, // Windows RT
/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i, // Windows Phone
/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i
/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i // Windows Phone
], [NAME, [VERSION, strMapper, windowsVersionMap]], [
/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i
], [[NAME, WINDOWS], [VERSION, strMapper, windowsVersionMap]], [
/windows nt 6\.2; (arm)/i, // Windows RT
/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,
/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i
], [[VERSION, strMapper, windowsVersionMap], [NAME, WINDOWS]], [

// iOS/macOS
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
Expand Down
4 changes: 2 additions & 2 deletions test/specs/browser-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@
"ua" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.901.400 QQBrowser/9.0.2524.400",
"expect" :
{
"name" : "WeChat(Win) Desktop",
"name" : "WeChat",
"version" : "3.43.901.400",
"major" : "3"
}
Expand All @@ -1753,7 +1753,7 @@
"ua" : "mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/53.0.2785.116 safari/537.36 qbcore/4.0.1301.400 qqbrowser/9.0.2524.400 mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, like gecko) chrome/81.0.4044.138 safari/537.36 nettype/wifi micromessenger/7.0.20.1781(0x6700143b) windowswechat",
"expect" :
{
"name" : "WeChat(Win) Desktop",
"name" : "WeChat",
"version" : "4.0.1301.400",
"major" : "4"
}
Expand Down
18 changes: 18 additions & 0 deletions test/specs/os-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@
"version" : "10"
}
},
{
"desc" : "WeChat Desktop for Windows Built-in Browser",
"ua" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.901.400 QQBrowser/9.0.2524.400",
"expect" :
{
"name" : "Windows",
"version" : "7"
}
},
{
"desc" : "WeChat Desktop for Windows Built-in Browser major version in 4",
"ua" : "mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, like gecko) chrome/81.0.4044.138 safari/537.36 nettype/wifi micromessenger/7.0.20.1781(0x6700143b) windowswechat",
"expect" :
{
"name" : "Windows",
"version" : "7"
}
},
{
"desc" : "Windows RT",
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",
Expand Down

0 comments on commit 17f0c1e

Please sign in to comment.