Skip to content

Commit

Permalink
Fix #722 - Add new browser name: Twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed May 17, 2024
1 parent 8dce4cc commit d0db40c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/enums/ua-parser-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const Browser = Object.freeze({
TESLA: 'Tesla',
TIKTOK: 'TikTok',
TIZEN: 'Tizen Browser',
TWITTER: 'Twitter',
UC: 'UCBrowser',
UP: 'UP.Browser',
VIERA: 'Viera',
Expand Down
3 changes: 2 additions & 1 deletion src/main/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
/safari (line)\/([\w\.]+)/i, // Line App for iOS
/\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
/(alipay)client\/([\w\.]+)/i, // Alipay
/(twitter)(?:and| f.+e\/([\w\.]+))/i, // Twitter
/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i // Chromium/Instagram/Snapchat
], [NAME, VERSION], [
/\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
Expand Down Expand Up @@ -521,7 +522,7 @@
/; (\w+) bui.+ oppo/i,
/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [
/\b(opd2\d{3}a?) bui\//i
/\b(opd2\d{3}a?) bui/i
], [MODEL, [VENDOR, 'OPPO'], [TYPE, TABLET]], [

// Vivo
Expand Down
20 changes: 20 additions & 0 deletions test/specs/browser-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -2071,5 +2071,25 @@
"version" : "12.33.0.36",
"major" : "12"
}
},
{
"desc" : "Twitter",
"ua" : "Mozilla/5.0 (Linux; Android 13; CPH2531 Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/123.0.6312.120 Mobile Safari/537.36 TwitterAndroid",
"expect" :
{
"name" : "Twitter",
"version" : "undefined",
"major" : "undefined"
}
},
{
"desc" : "Twitter",
"ua" : "Mozilla/5.0 (iPad; CPU OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/19H12 Twitter for iPhone/10.34",
"expect" :
{
"name" : "Twitter",
"version" : "10.34",
"major" : "10"
}
}
]

0 comments on commit d0db40c

Please sign in to comment.