Skip to content

Commit

Permalink
ObjectID creation handles hex string detection
Browse files Browse the repository at this point in the history
  • Loading branch information
nw committed Jun 16, 2010
1 parent 8b4130b commit 19fcc74
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/mongodb/bson/bson.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ var Code = exports.Code = function(code, scope) {
**/
var ObjectID = exports.ObjectID = function(id) {
id == null ? this.id = this.generate() : this.id = id;
if(id == null) this.id = this.generate();
else if( /^[0-9a-fA-F]{24}$/.test(id)) return ObjectID.createFromHexString(id);
else this.id = id;
};

ObjectID.prototype.get_inc = function() {
Expand Down

0 comments on commit 19fcc74

Please sign in to comment.