Skip to content

Commit

Permalink
Update version to 2.0.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Oct 2, 2023
1 parent 5a0d9cc commit ac282df
Show file tree
Hide file tree
Showing 12 changed files with 1,023 additions and 694 deletions.
4 changes: 2 additions & 2 deletions dist/ua-parser.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/ua-parser.pack.js

Large diffs are not rendered by default.

1,646 changes: 981 additions & 665 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'faisalman:ua-parser-js',
version: '2.0.0-alpha.3',
version: '2.0.0-beta.1',
summary: 'Lightweight JavaScript-based user-agent string parser',
git: 'https://github.com/faisalman/ua-parser-js.git',
documentation: 'readme.md'
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "UAParser.js",
"name": "ua-parser-js",
"version": "2.0.0-alpha.3",
"version": "2.0.0-beta.1",
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
"description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent & Client Hints data. Supports browser & node.js environment",
"keywords": [
Expand Down Expand Up @@ -228,8 +228,8 @@
"test": "test"
},
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
"demo": "https://faisalman.github.io/ua-parser-js",
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js",
"demo": "https://uaparser.js.org",
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.pack.js",
"funding": [
{
"type": "opencollective",
Expand Down
2 changes: 1 addition & 1 deletion src/enums/ua-parser-enums.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////
/* Enums for UAParser.js v2.0.0-beta
/* Enums for UAParser.js v2.0.0-beta.1
https://github.com/faisalman/ua-parser-js
Author: Faisal Salman <f@faisalman.com>
AGPLv3 License */
Expand Down
2 changes: 1 addition & 1 deletion src/enums/ua-parser-enums.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Source: /src/enums/ua-parser-enums.js

///////////////////////////////////////////////
/* Enums for UAParser.js v2.0.0-beta
/* Enums for UAParser.js v2.0.0-beta.1
https://github.com/faisalman/ua-parser-js
Author: Faisal Salman <f@faisalman.com>
AGPLv3 License */
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/ua-parser-extensions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////
/* Extensions for UAParser.js v2.0.0-beta
/* Extensions for UAParser.js v2.0.0-beta.1
https://github.com/faisalman/ua-parser-js
Author: Faisal Salman <f@faisalman.com>
AGPLv3 License */
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/ua-parser-extensions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Source: /src/extensions/ua-parser-extensions.js

///////////////////////////////////////////////
/* Extensions for UAParser.js v2.0.0-beta
/* Extensions for UAParser.js v2.0.0-beta.1
https://github.com/faisalman/ua-parser-js
Author: Faisal Salman <f@faisalman.com>
AGPLv3 License */
Expand Down
2 changes: 1 addition & 1 deletion src/main/ua-parser.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for UAParser.js v2.0.0-beta
// Type definitions for UAParser.js v2.0.0-beta.1
// Project: https://github.com/faisalman/ua-parser-js
// Definitions by: Faisal Salman <https://github.com/faisalman>

Expand Down
4 changes: 2 additions & 2 deletions src/main/ua-parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////////
/* UAParser.js v2.0.0-beta
/* UAParser.js v2.0.0-beta.1
Copyright © 2012-2023 Faisal Salman <f@faisalman.com>
AGPLv3 License *//*
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
Expand All @@ -20,7 +20,7 @@
/////////////


var LIBVERSION = '2.0.0-beta',
var LIBVERSION = '2.0.0-beta.1',
EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
Expand Down
41 changes: 27 additions & 14 deletions src/main/ua-parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Source: /src/main/ua-parser.js

/////////////////////////////////////////////////////////////////////////////////
/* UAParser.js v2.0.0-beta
/* UAParser.js v2.0.0-beta.1
Copyright © 2012-2023 Faisal Salman <f@faisalman.com>
AGPLv3 License *//*
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
Expand All @@ -22,7 +22,7 @@
/////////////


var LIBVERSION = '2.0.0-beta',
var LIBVERSION = '2.0.0-beta.1',
EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
Expand Down Expand Up @@ -131,10 +131,14 @@
itemListToArray = function (header) {
if (!header) return undefined;
var arr = [];
var tokens = strip(/\\?\"/g, header).split(', ');
var tokens = strip(/\\?\"/g, header).split(',');
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i].split(';v=');
arr[i] = { brand : token[0], version : token[1] };
if (tokens[i].indexOf(';') > -1) {
var token = trim(tokens[i]).split(';v=');
arr[i] = { brand : token[0], version : token[1] };
} else {
arr[i] = tokens[i];
}
}
return arr;
},
Expand All @@ -159,7 +163,7 @@
return str.replace(pattern, EMPTY);
},
stripQuotes = function (val) {
return typeof val === STR_TYPE ? strip(/\"/g, val) : val;
return typeof val === STR_TYPE ? strip(/\\?\"/g, val) : val;
},
trim = function (str, len) {
if (typeof(str) === STR_TYPE) {
Expand Down Expand Up @@ -241,7 +245,7 @@
return (i === UNKNOWN) ? undefined : i;
}
}
return str;
return map.hasOwnProperty('*') ? map['*'] : str;
};

///////////////
Expand All @@ -265,10 +269,11 @@
formFactorMap = {
'embedded' : 'Automotive',
'mobile' : 'Mobile',
'tablet' : 'Tablet',
'tablet' : ['Tablet', 'EInk'],
'smarttv' : 'TV',
'wearable' : ['VR', 'XR'],
'?' : 'Unknown'
'wearable' : ['VR', 'XR', 'Watch'],
'?' : ['Desktop', 'Unknown'],
'*' : undefined
};

//////////////
Expand Down Expand Up @@ -949,7 +954,7 @@
[PLATFORM, stripQuotes(uach[CH_HEADER_PLATFORM])],
[PLATFORMVER, stripQuotes(uach[CH_HEADER_PLATFORM_VER])],
[ARCHITECTURE, stripQuotes(uach[CH_HEADER_ARCH])],
[FORMFACTOR, stripQuotes(uach[CH_HEADER_FORM_FACTOR])],
[FORMFACTOR, itemListToArray(uach[CH_HEADER_FORM_FACTOR])],
[BITNESS, stripQuotes(uach[CH_HEADER_BITNESS])]
]);
} else {
Expand Down Expand Up @@ -1031,8 +1036,7 @@
};

this.parseCH = function () {
var ua = this.ua,
uaCH = this.uaCH,
var uaCH = this.uaCH,
rgxMap = this.rgxMap;

switch (this.itemType) {
Expand Down Expand Up @@ -1065,7 +1069,16 @@
this.set(MODEL, uaCH[MODEL]);
}
if (uaCH[FORMFACTOR]) {
this.set(TYPE, strMapper(uaCH[FORMFACTOR], formFactorMap));
var ff;
if (typeof uaCH[FORMFACTOR] !== 'string') {
var idx = 0;
while (!ff && idx < uaCH[FORMFACTOR].length) {
ff = strMapper(uaCH[FORMFACTOR][idx++], formFactorMap);
}
} else {
ff = strMapper(uaCH[FORMFACTOR], formFactorMap);
}
this.set(TYPE, ff);
}
break;
case UA_OS:
Expand Down

0 comments on commit ac282df

Please # to comment.