mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
parent
19af6a8f2e
commit
ace0ce17ea
@ -399,6 +399,12 @@ class Parser {
|
|||||||
let comparableVersion = version;
|
let comparableVersion = version;
|
||||||
let isLoose = false;
|
let isLoose = false;
|
||||||
|
|
||||||
|
const currentBrowserVersion = this.getBrowserVersion();
|
||||||
|
|
||||||
|
if (typeof currentBrowserVersion !== 'string') {
|
||||||
|
return void 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (version[0] === '>') {
|
if (version[0] === '>') {
|
||||||
expectedResult = 1;
|
expectedResult = 1;
|
||||||
comparableVersion = version.substr(1);
|
comparableVersion = version.substr(1);
|
||||||
@ -412,7 +418,7 @@ class Parser {
|
|||||||
comparableVersion = version.substr(1);
|
comparableVersion = version.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return compareVersions(this.getBrowserVersion(), comparableVersion, isLoose) === expectedResult;
|
return compareVersions(currentBrowserVersion, comparableVersion, isLoose) === expectedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
isOS(osName) {
|
isOS(osName) {
|
||||||
|
@ -984,6 +984,20 @@
|
|||||||
engine:
|
engine:
|
||||||
name: "WebKit"
|
name: "WebKit"
|
||||||
version: "601.1.46"
|
version: "601.1.46"
|
||||||
|
- ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15G77 [FBAN/FBIOS;FBDV/iPhone7,2;FBMD/iPhone;FBSN/iOS;FBSV/11.4.1;FBSS/2;FBCR/vfnl;FBID/phone;FBLC/nl_NL;FBOP/5;FBRV/0]"
|
||||||
|
spec:
|
||||||
|
browser:
|
||||||
|
name: "Safari"
|
||||||
|
os:
|
||||||
|
name: "iOS"
|
||||||
|
version: "11.4.1"
|
||||||
|
platform:
|
||||||
|
type: "mobile"
|
||||||
|
vendor: "Apple"
|
||||||
|
model: "iPhone"
|
||||||
|
engine:
|
||||||
|
name: "WebKit"
|
||||||
|
version: "605.1.15"
|
||||||
Internet Explorer:
|
Internet Explorer:
|
||||||
-
|
-
|
||||||
ua: "Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; MAARJS; rv:11.0) like Gecko"
|
ua: "Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; MAARJS; rv:11.0) like Gecko"
|
||||||
|
@ -57,7 +57,7 @@ test('Skip parsing shouldn\'t parse', (t) => {
|
|||||||
t.deepEqual((new Parser(UA, true)).getResult(), {});
|
t.deepEqual((new Parser(UA, true)).getResult(), {});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.check should make simple comparisons', (t) => {
|
test('Parser.satisfies should make simple comparisons', (t) => {
|
||||||
// also covers Parser.compareVersion() method
|
// also covers Parser.compareVersion() method
|
||||||
t.is(parser.satisfies({ opera: '>42' }), true);
|
t.is(parser.satisfies({ opera: '>42' }), true);
|
||||||
t.is(parser.satisfies({ opera: '<44' }), true);
|
t.is(parser.satisfies({ opera: '<44' }), true);
|
||||||
@ -66,7 +66,7 @@ test('Parser.check should make simple comparisons', (t) => {
|
|||||||
t.is(parser.satisfies({ opera: '~43' }), true);
|
t.is(parser.satisfies({ opera: '~43' }), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.check should make complex comparison', (t) => {
|
test('Parser.satisfies should make complex comparison', (t) => {
|
||||||
t.is(parser.satisfies({
|
t.is(parser.satisfies({
|
||||||
macos: {
|
macos: {
|
||||||
safari: '>11',
|
safari: '>11',
|
||||||
@ -78,7 +78,7 @@ test('Parser.check should make complex comparison', (t) => {
|
|||||||
}), true);
|
}), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Parser.check should respect platform and OS specific declarations', (t) => {
|
test('Parser.satisfies should respect platform and OS specific declarations', (t) => {
|
||||||
t.is(parser.satisfies({
|
t.is(parser.satisfies({
|
||||||
macos: {
|
macos: {
|
||||||
opera: '>45',
|
opera: '>45',
|
||||||
@ -114,6 +114,14 @@ test('Parser.check should respect platform and OS specific declarations', (t) =>
|
|||||||
}), void 0);
|
}), void 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.satisfies for versionless UA strings', (t) => {
|
||||||
|
const _parser = new Parser('Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15G77 [FBAN/FBIOS;FBDV/iPhone7,2;FBMD/iPhone;FBSN/iOS;FBSV/11.4.1;FBSS/2;FBCR/vfnl;FBID/phone;FBLC/nl_NL;FBOP/5;FBRV/0]');
|
||||||
|
|
||||||
|
t.is(_parser.satisfies({
|
||||||
|
safari: '>9',
|
||||||
|
}), void 0);
|
||||||
|
});
|
||||||
|
|
||||||
test('Parser.is should pass', (t) => {
|
test('Parser.is should pass', (t) => {
|
||||||
t.is(parser.is('opera'), true);
|
t.is(parser.is('opera'), true);
|
||||||
t.is(parser.is('desktop'), true);
|
t.is(parser.is('desktop'), true);
|
||||||
|
Loading…
Reference in New Issue
Block a user