File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ var ObjectID = function ObjectID(id) {
66
66
} else if ( id != null && id . length === 12 ) {
67
67
// assume 12 byte string
68
68
this . id = id ;
69
- } else if ( id != null && id . toHexString ) {
69
+ } else if ( id != null && typeof id . toHexString === 'function' ) {
70
70
// Duck-typing to support ObjectId from different npm packages
71
71
return id ;
72
72
} else {
@@ -357,7 +357,10 @@ ObjectID.isValid = function isValid(id) {
357
357
}
358
358
359
359
// Duck-Typing detection of ObjectId like objects
360
- if ( id . toHexString ) {
360
+ if (
361
+ typeof id . toHexString === 'function' &&
362
+ ( id . id instanceof _Buffer || typeof id . id === 'string' )
363
+ ) {
361
364
return id . id . length === 12 || ( id . id . length === 24 && checkForHexRegExp . test ( id . id ) ) ;
362
365
}
363
366
You can’t perform that action at this time.
0 commit comments