1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Merge branch 'release/1.4.5'

This commit is contained in:
Denis Demchenko 2016-08-30 00:26:22 +03:00
commit d5daa10f01
5 changed files with 51 additions and 10 deletions

View File

@ -1,5 +1,12 @@
# Bowser Changelog # Bowser Changelog
### 1.4.5 (August 30, 2016)
- [FIX] Add support of Samsung Internet for Android
- [FIX] Fix case when `navigator.userAgent` is `undefined`
- [DOC] Add information about `strictMode` in `check` function
- [DOC] Consistent use of `bowser` variable in the README
### 1.4.4 (August 10, 2016) ### 1.4.4 (August 10, 2016)
- [FIX] Fix AMD `define` call — pass name to the function - [FIX] Fix AMD `define` call — pass name to the function

View File

@ -16,7 +16,7 @@ We don't save built script in the repo anymore. The main file (`src/bowser.js`)
Also you can download minified file from [the release page](https://github.com/ded/bowser/releases). Also you can download minified file from [the release page](https://github.com/ded/bowser/releases).
## 1.0.0 breaking changes ## 1.0.0 breaking changes
`browser = require('bowser').browser;` becomes `browser = require('bowser');` `browser = require('bowser').browser;` becomes `bowser = require('bowser');`
--- ---
@ -31,24 +31,37 @@ Use it to get object with detected flags from User Agent string.
### bowser.check(minVersions`:Object`, strictMode`:Boolean`, [ua]`:String`)`:Boolean` ### bowser.check(minVersions`:Object`, strictMode`:Boolean`, [ua]`:String`)`:Boolean`
Use it to check if browser supported. Use it to check if browser supported.
``` ``` js
browser.check({msie: "11"}, window.navigator.userAgent); /**
// true / false * in case of using IE10
*/
bowser.check({msie: "11"}); // true
bowser.check({msie: "9.0"}); // false
/**
* specific user agent
*/
bowser.check({chrome: 45}, window.navigator.userAgent); // true
/**
* but false in strict mode
*/
bowser.check({chrome: 45}, true, window.navigator.userAgent); // false
``` ```
### bowser.compareVersions(versions`:Array<String>`)`:Number` ### bowser.compareVersions(versions`:Array<String>`)`:Number`
Use it to compare two versions. Use it to compare two versions.
``` ``` js
browser.compareVersions(['9.0', '10']); bowser.compareVersions(['9.0', '10']);
// -1 // -1
``` ```
### bowser.isUnsupportedBrowser(minVersions`:Object`, [strictMode]`:Boolean`, [ua]`:string`)`:Boolean` ### bowser.isUnsupportedBrowser(minVersions`:Object`, [strictMode]`:Boolean`, [ua]`:string`)`:Boolean`
Use it to check if browser is unsupported. Use it to check if browser is unsupported.
``` ``` js
browser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent); bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent);
// true / false // true / false
``` ```
@ -106,6 +119,7 @@ If detected, one of these flags may be set to true. The rendering engine flag i
* `android` - native browser - [`webkit`|`blink`] * `android` - native browser - [`webkit`|`blink`]
* `ios` - native browser - [`webkit`] * `ios` - native browser - [`webkit`]
* `opera` - [`blink` if >=15] * `opera` - [`blink` if >=15]
* `samsungBrowser` - [`blink`]
* `phantom` - [`webkit`] * `phantom` - [`webkit`]
* `blackberry` - native browser - [`webkit`] * `blackberry` - native browser - [`webkit`]
* `webos` - native browser - [`webkit`] * `webos` - native browser - [`webkit`]

View File

@ -7,7 +7,7 @@
"sniff", "sniff",
"detection" "detection"
], ],
"version": "1.4.4", "version": "1.4.5",
"homepage": "https://github.com/ded/bowser", "homepage": "https://github.com/ded/bowser",
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)", "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
"main": "./src/bowser.js", "main": "./src/bowser.js",

View File

@ -38,6 +38,7 @@
, tizen = /tizen/i.test(ua) , tizen = /tizen/i.test(ua)
, webos = /(web|hpw)os/i.test(ua) , webos = /(web|hpw)os/i.test(ua)
, windowsphone = /windows phone/i.test(ua) , windowsphone = /windows phone/i.test(ua)
, samsungBrowser = /SamsungBrowser/i.test(ua)
, windows = !windowsphone && /windows/i.test(ua) , windows = !windowsphone && /windows/i.test(ua)
, mac = !iosdevice && !silk && /macintosh/i.test(ua) , mac = !iosdevice && !silk && /macintosh/i.test(ua)
, linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua) , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
@ -55,6 +56,13 @@
, version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i) , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
} }
} }
else if (/SamsungBrowser/i.test(ua)) {
result = {
name: 'Samsung Internet for Android'
, samsungBrowser: t
, version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
}
}
else if (/coast/i.test(ua)) { else if (/coast/i.test(ua)) {
result = { result = {
name: 'Opera Coast' name: 'Opera Coast'
@ -372,6 +380,7 @@
(result.yandexbrowser && result.version >= 15) || (result.yandexbrowser && result.version >= 15) ||
(result.vivaldi && result.version >= 1.0) || (result.vivaldi && result.version >= 1.0) ||
(result.chrome && result.version >= 20) || (result.chrome && result.version >= 20) ||
(result.samsungBrowser && result.version >= 4) ||
(result.firefox && result.version >= 20.0) || (result.firefox && result.version >= 20.0) ||
(result.safari && result.version >= 6) || (result.safari && result.version >= 6) ||
(result.opera && result.version >= 10.0) || (result.opera && result.version >= 10.0) ||
@ -395,7 +404,7 @@
return result return result
} }
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '') var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
bowser.test = function (browserList) { bowser.test = function (browserList) {
for (var i = 0; i < browserList.length; ++i) { for (var i = 0; i < browserList.length; ++i) {

View File

@ -1264,4 +1264,15 @@ module.exports.useragents = {
, x: true , x: true
} }
} }
, 'Samsung Internet for Android' : {
'Mozilla/5.0 (Linux; Android 5.0.2; SAMSUNG SM-G925F Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36': {
mobile: true
, android: true
, osversion: '5.0.2'
, samsungBrowser: true
, version: '4.0'
, a: true
, blink: true
}
}
} }