File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 806
806
return _ua ;
807
807
} ;
808
808
this . setUA = function ( ua ) {
809
- _ua = ua . length > UA_MAX_LENGTH ? util . trim ( ua , UA_MAX_LENGTH ) : ua ;
809
+ _ua = ( typeof ua === STR_TYPE && ua . length > UA_MAX_LENGTH ) ? util . trim ( ua , UA_MAX_LENGTH ) : ua ;
810
810
return this ;
811
811
} ;
812
812
this . setUA ( _ua ) ;
Original file line number Diff line number Diff line change @@ -46,6 +46,14 @@ describe('UAParser()', function () {
46
46
assert . deepStrictEqual ( UAParser ( ua ) , new UAParser ( ) . setUA ( ua ) . getResult ( ) ) ;
47
47
} ) ;
48
48
49
+ describe ( 'UAParser() constructor does not throw with undefined ua argument' , function ( ) {
50
+ assert . doesNotThrow ( ( ) => new UAParser ( undefined ) . getResult ( ) ) ;
51
+ } ) ;
52
+
53
+ describe ( 'UAParser.setUA method does not throw with undefined ua argument' , function ( ) {
54
+ assert . doesNotThrow ( ( ) => new UAParser ( ) . setUA ( undefined ) . getResult ( ) ) ;
55
+ } ) ;
56
+
49
57
for ( var i in methods ) {
50
58
describe ( methods [ i ] [ 'title' ] , function ( ) {
51
59
for ( var j in methods [ i ] [ 'list' ] ) {
You can’t perform that action at this time.
0 commit comments