Skip to content

Commit f3de7b7

Browse files
committed
Backport - Improve browser detection: WeChat (cherry picked from commit 17f0c1e)
1 parent c41100e commit f3de7b7

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/ua-parser.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@
244244
/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
245245
], [VERSION, [NAME, 'UC'+BROWSER]], [
246246
/microm.+\bqbcore\/([\w\.]+)/i, // WeChat Desktop for Windows Built-in Browser
247-
/\bqbcore\/([\w\.]+).+microm/i
248-
], [VERSION, [NAME, 'WeChat(Win) Desktop']], [
247+
/\bqbcore\/([\w\.]+).+microm/i,
249248
/micromessenger\/([\w\.]+)/i // WeChat
250249
], [VERSION, [NAME, 'WeChat']], [
251250
/konqueror\/([\w\.]+)/i // Konqueror
@@ -727,12 +726,12 @@
727726
// Windows
728727
/microsoft (windows) (vista|xp)/i // Windows (iTunes)
729728
], [NAME, VERSION], [
730-
/(windows) nt 6\.2; (arm)/i, // Windows RT
731-
/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i, // Windows Phone
732-
/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i
729+
/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i // Windows Phone
733730
], [NAME, [VERSION, strMapper, windowsVersionMap]], [
734-
/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i
735-
], [[NAME, 'Windows'], [VERSION, strMapper, windowsVersionMap]], [
731+
/windows nt 6\.2; (arm)/i, // Windows RT
732+
/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,
733+
/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i
734+
], [[VERSION, strMapper, windowsVersionMap], [NAME, 'Windows']], [
736735

737736
// iOS/macOS
738737
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS

test/browser-test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@
17131713
"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",
17141714
"expect" :
17151715
{
1716-
"name" : "WeChat(Win) Desktop",
1716+
"name" : "WeChat",
17171717
"version" : "3.43.901.400",
17181718
"major" : "3"
17191719
}
@@ -1723,7 +1723,7 @@
17231723
"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",
17241724
"expect" :
17251725
{
1726-
"name" : "WeChat(Win) Desktop",
1726+
"name" : "WeChat",
17271727
"version" : "4.0.1301.400",
17281728
"major" : "4"
17291729
}

test/os-test.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@
8080
"version" : "10"
8181
}
8282
},
83+
{
84+
"desc" : "WeChat Desktop for Windows Built-in Browser",
85+
"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",
86+
"expect" :
87+
{
88+
"name" : "Windows",
89+
"version" : "7"
90+
}
91+
},
92+
{
93+
"desc" : "WeChat Desktop for Windows Built-in Browser major version in 4",
94+
"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",
95+
"expect" :
96+
{
97+
"name" : "Windows",
98+
"version" : "7"
99+
}
100+
},
83101
{
84102
"desc" : "Windows RT",
85103
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",

0 commit comments

Comments
 (0)