mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge pull request #83 from hansman/master
Parse user agent by default according to spec.
This commit is contained in:
commit
c70fdce0e3
@ -16,6 +16,11 @@
|
||||
return (match && match.length > 1 && match[1]) || '';
|
||||
}
|
||||
|
||||
function getSecondMatch(regex) {
|
||||
var match = ua.match(regex);
|
||||
return (match && match.length > 1 && match[2]) || '';
|
||||
}
|
||||
|
||||
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
||||
, likeAndroid = /like android/i.test(ua)
|
||||
, android = !likeAndroid && /android/i.test(ua)
|
||||
@ -142,7 +147,12 @@
|
||||
, version: versionIdentifier
|
||||
}
|
||||
}
|
||||
else result = {}
|
||||
else {
|
||||
result = {
|
||||
name: getFirstMatch(/^(.*)\/(.*) /),
|
||||
version: getSecondMatch(/^(.*)\/(.*) /)
|
||||
};
|
||||
}
|
||||
|
||||
// set webkit or gecko flag for browsers based on these engines
|
||||
if (/(apple)?webkit/i.test(ua)) {
|
||||
|
@ -931,4 +931,11 @@ module.exports.useragents = {
|
||||
, x: true
|
||||
}
|
||||
}
|
||||
, Generic: {
|
||||
'Generic/2.15 libww': {
|
||||
name: 'Generic'
|
||||
, version: '2.15'
|
||||
, x: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user