[fix] setUA(): remove trailing space from user-agent string

This commit is contained in:
Faisal Salman
2025-10-05 21:01:32 +07:00
parent 5749302c47
commit b3bc89c463
2 changed files with 11 additions and 6 deletions

View File

@@ -163,6 +163,14 @@ describe('Extending Regex', function () {
assert.deepEqual(myParser3.setUA(myUA2).getDevice(), {vendor: "MyTab", model: "14 Pro Max", type: "tablet"});
});
describe('User-agent with trailing space', function () {
it ('trailing space will be trimmed', function () {
const uastring = ' Opera/9.21 (Windows NT 5.1; U; ru) ';
const { ua } = UAParser(uastring);
assert.equal(ua, 'Opera/9.21 (Windows NT 5.1; U; ru) ');
});
});
describe('User-agent length', function () {
var UA_MAX_LENGTH = 500;