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 {
8585 } else if ( id != null && id . length === 12 ) {
8686 // assume 12 byte string
8787 this . id = id ;
88- } else if ( id != null && id . toHexString ) {
88+ } else if ( id != null && typeof id . toHexString === 'function' ) {
8989 // Duck-typing to support ObjectId from different npm packages
9090 return ObjectId . createFromHexString ( id . toHexString ( ) ) ;
9191 } else {
@@ -338,7 +338,10 @@ class ObjectId {
338338 }
339339
340340 // 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+ ) {
342345 return id . id . length === 12 || ( id . id . length === 24 && checkForHexRegExp . test ( id . id ) ) ;
343346 }
344347
You can’t perform that action at this time.
0 commit comments