mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
Only check for direct properties from the headers object
This commit is contained in:
parent
3e65196b57
commit
fb1ed5cf6b
@ -1400,7 +1400,9 @@
|
||||
// Normalize headers field name into lowercase
|
||||
var normalized = {};
|
||||
for (var header in headers) {
|
||||
normalized[String(header).toLowerCase()] = headers[header];
|
||||
if (headers.hasOwnProperty(header)) {
|
||||
normalized[String(header).toLowerCase()] = headers[header];
|
||||
}
|
||||
}
|
||||
headers = normalized;
|
||||
}
|
||||
|
@ -389,4 +389,10 @@ describe('Read user-agent data from req.headers', function () {
|
||||
const { browser } = UAParser(hEaDeRs);
|
||||
assert.strictEqual(browser.toString(), "Midori 0.2.2");
|
||||
});
|
||||
|
||||
it('Empty headers should not raise any error', function () {
|
||||
const emptyHeaders = {};
|
||||
const { browser } = UAParser(emptyHeaders);
|
||||
assert.strictEqual(browser.toString(), "undefined");
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user