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 @@ -85,7 +85,7 @@ class ObjectId {
85
85
} else if ( id != null && id . length === 12 ) {
86
86
// assume 12 byte string
87
87
this . id = id ;
88
- } else if ( id != null && id . toHexString ) {
88
+ } else if ( id != null && typeof id . toHexString === 'function' ) {
89
89
// Duck-typing to support ObjectId from different npm packages
90
90
return ObjectId . createFromHexString ( id . toHexString ( ) ) ;
91
91
} else {
@@ -338,7 +338,10 @@ class ObjectId {
338
338
}
339
339
340
340
// Duck-Typing detection of ObjectId like objects
341
- if ( id . toHexString ) {
341
+ if (
342
+ typeof id . toHexString === 'function' &&
343
+ ( id . id instanceof _Buffer || typeof id . id === 'string' )
344
+ ) {
342
345
return id . id . length === 12 || ( id . id . length === 24 && checkForHexRegExp . test ( id . id ) ) ;
343
346
}
344
347
You can’t perform that action at this time.
0 commit comments