Skip to content

Commit 24950f9

Browse files
committed
Merge branch 'master' of github.com:faisalman/ua-parser-js into master
2 parents 9d431cf + cb30756 commit 24950f9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/ua-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@
806806
return _ua;
807807
};
808808
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;
810810
return this;
811811
};
812812
this.setUA(_ua);

test/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ describe('UAParser()', function () {
4646
assert.deepStrictEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
4747
});
4848

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+
4957
for (var i in methods) {
5058
describe(methods[i]['title'], function () {
5159
for (var j in methods[i]['list']) {

0 commit comments

Comments
 (0)