mirror of
https://github.com/lancedikson/bowser
synced 2025-06-13 13:03:52 +00:00
Added normalize function to get the first number of the browser version and using that one for bowser.version probably a solution to enable graded browser support (it wasn't working for me before)
This commit is contained in:
parent
3f29ac628e
commit
45af8a7231
14
bowser.js
14
bowser.js
@ -22,38 +22,42 @@
|
||||
firefox = /firefox/i.test(ua),
|
||||
gecko = /gecko\//i.test(ua);
|
||||
|
||||
function normalize(ua, pattern){
|
||||
return +ua.match(pattern)[1].split(".")[0]
|
||||
}
|
||||
|
||||
function detect() {
|
||||
|
||||
if (ie) {
|
||||
return {
|
||||
msie: t,
|
||||
version: ua.match(/msie ([\d\.]+);/i)[1]
|
||||
version: normalize(ua, /msie ([\d\.]+);/i)
|
||||
};
|
||||
}
|
||||
if (chrome) {
|
||||
return {
|
||||
webkit: t,
|
||||
chrome: t,
|
||||
version: ua.match(/chrome\/([\d\.]+)/i)[1]
|
||||
version: normalize(ua, /chrome\/([\d\.]+)/i)
|
||||
};
|
||||
}
|
||||
if (safari) {
|
||||
return {
|
||||
webkit: t,
|
||||
safari: t,
|
||||
version: ua.match(/version\/([\d\.]+)/i)[1]
|
||||
version: normalize(ua, /version\/([\d\.]+)/i)
|
||||
};
|
||||
}
|
||||
if (opera) {
|
||||
return {
|
||||
opera: t,
|
||||
version: ua.match(/version\/([\d\.]+)/i)[1]
|
||||
version: normalize(ua, /version\/([\d\.]+)/i)
|
||||
};
|
||||
}
|
||||
if (gecko) {
|
||||
var o = {
|
||||
gecko: t,
|
||||
version: ua.match(/firefox\/([\d\.]+)/i)[1]
|
||||
version: unormalize(ua, /firefox\/([\d\.]+)/i)
|
||||
};
|
||||
if (firefox) {
|
||||
o.firefox = t;
|
||||
|
Loading…
Reference in New Issue
Block a user