mirror of
https://github.com/lancedikson/bowser
synced 2026-03-02 03:40:27 +00:00
Fix Bowser constructor, add some tests
This commit is contained in:
@@ -17,21 +17,22 @@ import Parser from './parser';
|
||||
class Bowser {
|
||||
/**
|
||||
* Creates an object that parses UA
|
||||
* @param UA
|
||||
* @param {String} UA — UserAgent string
|
||||
* @param {Boolean} [skipParsing=false] — same as skipParsing for Parser
|
||||
*
|
||||
* @example
|
||||
* const bowser = new Bowser(window.navigator.userAgent);
|
||||
* bowser.getBrowser()
|
||||
*/
|
||||
constructor(UA) {
|
||||
constructor(UA, skipParsing=false) {
|
||||
if (!UA) {
|
||||
throw new Error('UserAgent is not defined');
|
||||
}
|
||||
return new Parser(UA);
|
||||
return new Parser(UA, skipParsing);
|
||||
}
|
||||
|
||||
static parse(UA) {
|
||||
return (new this.constructor(UA)).getResult();
|
||||
return (new Bowser(UA)).getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user