mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge pull request #85 from jdalton/msedge
Add support for Microsoft Edge.
This commit is contained in:
commit
bb35c3ddaf
@ -16,6 +16,7 @@ if (bowser.msie && bowser.version <= 6) {
|
||||
* `chrome`[`webkit`]
|
||||
* `firefox`[`gecko`]
|
||||
* `msie`
|
||||
* `msedge`
|
||||
* Android native browser as `android`[`webkit`]
|
||||
* iOS native browser as `ios`[`webkit`]
|
||||
* `opera`[`webkit` if >12]
|
||||
|
@ -24,6 +24,7 @@
|
||||
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
||||
, likeAndroid = /like android/i.test(ua)
|
||||
, android = !likeAndroid && /android/i.test(ua)
|
||||
, edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i)
|
||||
, versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
|
||||
, tablet = /tablet/i.test(ua)
|
||||
, mobile = !tablet && /[^-]mobi/i.test(ua)
|
||||
@ -40,8 +41,14 @@
|
||||
result = {
|
||||
name: 'Windows Phone'
|
||||
, windowsphone: t
|
||||
, msie: t
|
||||
, version: getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
if (edgeVersion) {
|
||||
result.msedge = t
|
||||
result.version = edgeVersion
|
||||
}
|
||||
else {
|
||||
result.msie = t
|
||||
result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/msie|trident/i.test(ua)) {
|
||||
@ -51,6 +58,13 @@
|
||||
, version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/chrome.+? edge/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Microsoft Edge'
|
||||
, msedge: t
|
||||
, version: edgeVersion
|
||||
}
|
||||
}
|
||||
else if (/chrome|crios|crmo/i.test(ua)) {
|
||||
result = {
|
||||
name: 'Chrome'
|
||||
@ -155,7 +169,7 @@
|
||||
}
|
||||
|
||||
// set webkit or gecko flag for browsers based on these engines
|
||||
if (/(apple)?webkit/i.test(ua)) {
|
||||
if (!result.msedge && /(apple)?webkit/i.test(ua)) {
|
||||
result.name = result.name || "Webkit"
|
||||
result.webkit = t
|
||||
if (!result.version && versionIdentifier) {
|
||||
@ -168,7 +182,7 @@
|
||||
}
|
||||
|
||||
// set OS flags for platforms that have multiple browsers
|
||||
if (android || result.silk) {
|
||||
if (!result.msedge && (android || result.silk)) {
|
||||
result.android = t
|
||||
} else if (iosdevice) {
|
||||
result[iosdevice] = t
|
||||
@ -177,13 +191,13 @@
|
||||
|
||||
// OS version extraction
|
||||
var osVersion = '';
|
||||
if (iosdevice) {
|
||||
if (result.windowsphone) {
|
||||
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
|
||||
} else if (iosdevice) {
|
||||
osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
|
||||
osVersion = osVersion.replace(/[_\s]/g, '.');
|
||||
} else if (android) {
|
||||
osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
|
||||
} else if (result.windowsphone) {
|
||||
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
|
||||
} else if (result.webos) {
|
||||
osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
|
||||
} else if (result.blackberry) {
|
||||
@ -207,7 +221,8 @@
|
||||
|
||||
// Graded Browser Support
|
||||
// http://developer.yahoo.com/yui/articles/gbs
|
||||
if ((result.msie && result.version >= 10) ||
|
||||
if (result.msedge ||
|
||||
(result.msie && result.version >= 10) ||
|
||||
(result.chrome && result.version >= 20) ||
|
||||
(result.firefox && result.version >= 20.0) ||
|
||||
(result.safari && result.version >= 6) ||
|
||||
|
@ -358,6 +358,13 @@ module.exports.useragents = {
|
||||
, c: true
|
||||
}
|
||||
}
|
||||
, 'Microsoft Edge': {
|
||||
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0': {
|
||||
msedge: true
|
||||
, version: '12.0'
|
||||
, a: true
|
||||
}
|
||||
}
|
||||
, Firefox: {
|
||||
'Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0': {
|
||||
gecko: true
|
||||
@ -735,6 +742,14 @@ module.exports.useragents = {
|
||||
, mobile: true
|
||||
, c: true
|
||||
}
|
||||
, 'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0': {
|
||||
windowsphone: true
|
||||
, osversion: '10.0'
|
||||
, msedge: true
|
||||
, version: '12.0'
|
||||
, mobile: true
|
||||
, a: true
|
||||
}
|
||||
}
|
||||
, WebOS: {
|
||||
'Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.5; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0': {
|
||||
|
Loading…
Reference in New Issue
Block a user