Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit b1d885a

Browse files
committed
use Object.prototype.toString()
1 parent 86d66af commit b1d885a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,6 @@ function intersect_safe(a, b)
469469

470470
function sanitize_user(u) {
471471
if (u['key']) {
472-
u['key'] = "" + u['key'];
472+
u['key'] = u['key'].toString();
473473
}
474474
}

test/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,10 @@ describe('sanitize_user', function () {
171171
sanitize_user(u);
172172
assert.deepStrictEqual(u0, u);
173173
});
174+
it('should not blow up if the key is missing', function () {
175+
var u = {firstName: 'alice'};
176+
var u0 = {firstName: 'alice'};
177+
sanitize_user(u);
178+
assert.deepStrictEqual(u0, u);
179+
});
174180
});

0 commit comments

Comments
 (0)