mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
Make sure the result only get constructed once
This commit is contained in:
parent
ec40433c5c
commit
51822ad172
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "UA-Parser.JS",
|
"title": "UA-Parser.JS",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "0.3.4",
|
"version": "0.3.5",
|
||||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
22
ua-parser.js
22
ua-parser.js
@ -1,4 +1,4 @@
|
|||||||
// UA-Parser.JS v0.3.4
|
// UA-Parser.JS v0.3.5
|
||||||
// Lightweight JavaScript-based User-Agent string parser
|
// Lightweight JavaScript-based User-Agent string parser
|
||||||
// https://github.com/faisalman/ua-parser-js
|
// https://github.com/faisalman/ua-parser-js
|
||||||
//
|
//
|
||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
var regexMapper = function (ua, args) {
|
var regexMapper = function (ua, args) {
|
||||||
|
|
||||||
var result = {}, i, j, k, l, m;
|
var result, i, j, k, l, m;
|
||||||
|
|
||||||
// loop through all regexes maps
|
// loop through all regexes maps
|
||||||
for (i = 1; i < arguments.length; i += 2) {
|
for (i = 1; i < arguments.length; i += 2) {
|
||||||
@ -18,11 +18,17 @@
|
|||||||
props = arguments[i + 1]; // odd sequence (2,4,6,..)
|
props = arguments[i + 1]; // odd sequence (2,4,6,..)
|
||||||
|
|
||||||
// build object barebones
|
// build object barebones
|
||||||
for (k = 0; k < props.length; k++) {
|
if (typeof result === 'undefined') {
|
||||||
if (typeof props[k] === 'object') {
|
result = {};
|
||||||
result[props[k][0]] = undefined;
|
for (k = 0; k < props.length; k++) {
|
||||||
} else {
|
if (typeof props[k] === 'object') {
|
||||||
result[props[k]] = undefined;
|
result[props[k][0]] = undefined;
|
||||||
|
} else {
|
||||||
|
result[props[k]] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ua.toString() === '') {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +223,7 @@
|
|||||||
/sec-((sgh\w+))/i
|
/sec-((sgh\w+))/i
|
||||||
], [['name', 'Samsung'], 'version'], [
|
], [['name', 'Samsung'], 'version'], [
|
||||||
|
|
||||||
/((transfo[prime\s]{4,10}\s\w+|(?:android.*)eeepc))/i // Asus
|
/((transfo[prime\s]{4,10}\s\w+))|(?:android.*)((eeepc))/i // Asus
|
||||||
], [['name', 'Asus'], 'version'], [
|
], [['name', 'Asus'], 'version'], [
|
||||||
|
|
||||||
/(sie)-(\w+)*/i // Siemens
|
/(sie)-(\w+)*/i // Siemens
|
||||||
|
Loading…
x
Reference in New Issue
Block a user