mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Maps object should contains only data
This commit is contained in:
parent
41b3e247a4
commit
bf9c8de5c4
@ -1,7 +1,7 @@
|
||||
{
|
||||
"title": "UA-Parser.JS",
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"keywords": [
|
||||
|
16
ua-parser.js
16
ua-parser.js
@ -1,4 +1,4 @@
|
||||
// UA-Parser.JS v0.4.0
|
||||
// UA-Parser.JS v0.4.1
|
||||
// Lightweight JavaScript-based User-Agent string parser
|
||||
// https://github.com/faisalman/ua-parser-js
|
||||
//
|
||||
@ -45,7 +45,11 @@
|
||||
if (typeof props[k] === 'object' && props[k].length === 2) {
|
||||
result[props[k][0]] = props[k][1];
|
||||
} else if (typeof props[k] === 'object' && props[k].length === 3) {
|
||||
if (typeof props[k][1] === 'function') {
|
||||
result[props[k][0]] = m ? props[k][1].call(this, m, props[k][2]) : undefined;
|
||||
} else {
|
||||
result[props[k][0]] = m ? m.replace(props[k][1], props[k][2]) : undefined;
|
||||
}
|
||||
} else {
|
||||
result[props[k]] = m ? m : undefined;
|
||||
}
|
||||
@ -81,8 +85,7 @@
|
||||
var maps = {
|
||||
os : {
|
||||
windows : {
|
||||
version : function (match, str1) {
|
||||
return mapper.string(str1, {
|
||||
version : {
|
||||
'ME' : '4.90',
|
||||
'NT 3.11' : 'nt3.51',
|
||||
'NT 4.0' : 'nt4.0',
|
||||
@ -91,7 +94,6 @@
|
||||
'Vista' : 'nt 6.0',
|
||||
'7' : 'nt 6.1',
|
||||
'8' : 'nt 6.2'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,9 +194,9 @@
|
||||
|
||||
// Windows based
|
||||
/(windows\sphone\sos|windows)\s?([ntce\d\.\s]+\d)/i // Windows
|
||||
], ['name', ['version', /(.+)/gi, maps.os.windows.version]], [
|
||||
], ['name', ['version', mapper.string, maps.os.windows.version]], [
|
||||
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
|
||||
], [['name', 'Windows'], ['version', /(.+)/gi, maps.os.windows.version]], [
|
||||
], [['name', 'Windows'], ['version', mapper.string, maps.os.windows.version]], [
|
||||
|
||||
// Mobile/Embedded OS
|
||||
/(blackberry).+version\/([\w\.]+)/i, // Blackberry
|
||||
@ -223,7 +225,7 @@
|
||||
], ['name', 'version'],[
|
||||
|
||||
/(ip[honead]+).*os\s*([\w]+)*\slike\smac/i // iOS
|
||||
], [['name', /.+/g, 'iOS'], ['version', /_/g, '.']], [
|
||||
], [['name', 'iOS'], ['version', /_/g, '.']], [
|
||||
|
||||
/(mac\sos\sx)\s([\w\s\.]+\w)/i, // Mac OS
|
||||
], ['name', ['version', /_/g, '.']], [
|
||||
|
Loading…
x
Reference in New Issue
Block a user