Skip to content

Commit

Permalink
Return both mayor and minor version on Browser.version
Browse files Browse the repository at this point in the history
  • Loading branch information
fedegratti committed May 29, 2023
1 parent 962f639 commit 575743c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10.3.0
v10.3.1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ohzi-core",
"version": "10.3.0",
"version": "10.3.1",
"description": "OHZI Core Library",
"source": "src/index.js",
"module": "build/index.module.js",
Expand Down
5 changes: 4 additions & 1 deletion src/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Browser
let version = 0;

let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];

if (/trident/i.test(M[1]))
{
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
Expand All @@ -94,8 +95,10 @@ class Browser
tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
if (tem != null) version = tem.slice(1).join(' ').replace('OPR', 'Opera');
}

M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]);
if ((tem = ua.match(/version\/(\d+(\.\d+)?)/i)) != null) M.splice(1, 1, tem[1]);

version = M.join(' ');

return Number(version.split(' ')[1]);
Expand Down

0 comments on commit 575743c

Please sign in to comment.