Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Update macOS user agent regex to match macOS Big Sur versions.
Browse files Browse the repository at this point in the history
RELNOTES: Update macOS user agent regex to match macOS Big Sur versions.

PiperOrigin-RevId: 344267790
  • Loading branch information
Closure Team authored and kjin committed Nov 30, 2020
1 parent 47d92ae commit f4ae8e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion closure/goog/useragent/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ goog.userAgent.platform.determineVersion_ = function() {
return '0';
}
} else if (goog.userAgent.MAC) {
re = /10[_.][0-9_.]+/;
re = /1[0|1][_.][0-9_.]+/;
var match = re.exec(goog.userAgent.getUserAgentString());
// Note: some old versions of Camino do not report an OSX version.
// Default to 10.
Expand Down
8 changes: 8 additions & 0 deletions closure/goog/useragent/platform_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ testSuite({
const ff = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;' +
'rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 GTB6';

const chrome_osx_11 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0)' +
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66' +
'Safari/537.36';

mockAgent.setNavigator({platform: 'IntelMac'});

mockAgent.setUserAgentString(chrome);
Expand All @@ -84,6 +88,10 @@ testSuite({
mockAgent.setUserAgentString(ff);
updateUserAgentUtils();
assertEquals('10.5', platform.VERSION);

mockAgent.setUserAgentString(chrome_osx_11);
updateUserAgentUtils();
assertEquals('11.1.0', platform.VERSION);
},

testChromeOnAndroid() {
Expand Down

0 comments on commit f4ae8e1

Please sign in to comment.