Skip to content

Commit

Permalink
fix browser name in mobile device
Browse files Browse the repository at this point in the history
  • Loading branch information
becher committed Aug 10, 2022
1 parent aad0c9d commit ff4e1b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/angular-device-information/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Dependencies

**Angular-device-information 1.0.0** is available for **Angular 9.x** to **Angular 13.x**
**Angular-device-information 1.0.6** is available for **Angular 8.x** to **Angular 14.x**

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,21 @@ export class AngularDeviceInformationService {
version = version.substring(0, ix);
}

browser = (function() {
var test = function(regexp) {return regexp.test(window.navigator.userAgent)}
switch (true) {
case test(/edg/i): return "Microsoft Edge";
case test(/trident/i): return "Microsoft Internet Explorer";
case test(/firefox|fxios/i): return "Mozilla Firefox";
case test(/opr\//i): return "Opera";
case test(/ucbrowser/i): return "UC Browser";
case test(/samsungbrowser/i): return "Samsung Browser";
case test(/chrome|chromium|crios/i): return "Google Chrome";
case test(/safari/i): return "Apple Safari";
default: return "Other";
}
})();

majorVersion = parseInt('' + version, 10);
if (isNaN(majorVersion)) {
version = '' + parseFloat(navigator.appVersion);
Expand Down Expand Up @@ -208,7 +223,7 @@ export class AngularDeviceInformationService {
osVersion = osVersion.replaceAll('_', '.');
break;
case 'iOS':
osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nAgt);
osVersion = osVersion[1] + '.' + osVersion[2] + '.' + (osVersion[3] | 0);
osVersion = osVersion.replaceAll('_', '.');
break;
Expand Down

0 comments on commit ff4e1b8

Please sign in to comment.