mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Add string check to setUA method
This commit is contained in:
parent
c937400e8e
commit
0868e372e0
@ -804,7 +804,7 @@
|
|||||||
return _ua;
|
return _ua;
|
||||||
};
|
};
|
||||||
this.setUA = function (ua) {
|
this.setUA = function (ua) {
|
||||||
_ua = ua.length > UA_MAX_LENGTH ? util.trim(ua, UA_MAX_LENGTH) : ua;
|
_ua = (typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH) ? util.trim(ua, UA_MAX_LENGTH) : ua;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
this.setUA(_ua);
|
this.setUA(_ua);
|
||||||
|
@ -46,6 +46,14 @@ describe('UAParser()', function () {
|
|||||||
assert.deepStrictEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
|
assert.deepStrictEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('UAParser() constructor does not throw with undefined ua argument', function () {
|
||||||
|
assert.doesNotThrow(() => new UAParser(undefined).getResult());
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('UAParser.setUA method does not throw with undefined ua argument', function () {
|
||||||
|
assert.doesNotThrow(() => new UAParser().setUA(undefined).getResult());
|
||||||
|
});
|
||||||
|
|
||||||
for (var i in methods) {
|
for (var i in methods) {
|
||||||
describe(methods[i]['title'], function () {
|
describe(methods[i]['title'], function () {
|
||||||
for (var j in methods[i]['list']) {
|
for (var j in methods[i]['list']) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user