Comparing version 3.2.0 to 3.2.1
12
index.js
@@ -1,4 +0,2 @@ | ||
var inherits = require('util').inherits | ||
var ObjectId = require('bson').ObjectId | ||
var toString = require('to-string') | ||
@@ -11,3 +9,3 @@ ObjectId.prototype.equals = function (oidB) { | ||
var isValid = function (alleged) { | ||
return (!!alleged && objIdPattern.test(toString(alleged))) | ||
return (Boolean(alleged) && !Array.isArray(alleged) && objIdPattern.test(String(alleged))) | ||
} | ||
@@ -24,4 +22,4 @@ | ||
if (oidA === oidB) { return true; } | ||
if (!oidA || !oidB) { return false } | ||
return (oidA.toString() === oidB.toString()) | ||
if (!isValid(oidA) || !isValid(oidB)) { return false } | ||
return (String(oidA) === String(oidB)) | ||
return false; | ||
@@ -47,3 +45,3 @@ } | ||
id = toString(id) | ||
id = String(id) | ||
@@ -63,2 +61,2 @@ if (isValid(id)) { | ||
module.exports.equals = equals; | ||
module.exports.isValid = isValid; | ||
module.exports.isValid = isValid; |
{ | ||
"name": "objectid", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "mongodb objectid utilities", | ||
@@ -24,13 +24,11 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mongodb": "~1.2.12", | ||
"bson": "~0.1.8", | ||
"chai": "~1.5.0", | ||
"chai-interface": "~1.1.0", | ||
"mocha": "~1.8.2", | ||
"chai-interface": "~1.1.0", | ||
"bson": "~0.1.8" | ||
"mongodb": "~1.2.12" | ||
}, | ||
"dependencies": { | ||
"mongodb": "~1.3.3", | ||
"bson": "~0.1.8", | ||
"to-string": "~0.2.0" | ||
"bson": "^0.1.9" | ||
} | ||
} |
@@ -132,2 +132,6 @@ var chai = require('chai') | ||
it('false for 1-element array of ObjectId', function () { | ||
ObjectId.isValid([ObjectId()]).should.equal(false) | ||
}) | ||
}) | ||
@@ -146,4 +150,5 @@ | ||
}) | ||
it('returns false otherwise', function () { | ||
it('returns false if A or B are not ObjectIds', function () { | ||
ObjectId.equals('sdfsdfsdfsdf', testOid).should.equal(false) | ||
ObjectId.equals('511083bb08ce6b1b00000003', ['511083bb08ce6b1b00000003']).should.equal(false) | ||
}) | ||
@@ -150,0 +155,0 @@ it('is also on ObjectId.prototype', function () { |
9972
1
206
- Removedmongodb@~1.3.3
- Removedto-string@~0.2.0
- Removedbson@0.2.5(transitive)
- Removedkerberos@0.0.3(transitive)
- Removedmongodb@1.3.23(transitive)
- Removedto-string@0.2.0(transitive)
Updatedbson@^0.1.9