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) {
6666 } else if ( id != null && id . length === 12 ) {
6767 // assume 12 byte string
6868 this . id = id ;
69- } else if ( id != null && id . toHexString ) {
69+ } else if ( id != null && typeof id . toHexString === 'function' ) {
7070 // Duck-typing to support ObjectId from different npm packages
7171 return id ;
7272 } else {
@@ -357,7 +357,10 @@ ObjectID.isValid = function isValid(id) {
357357 }
358358
359359 // 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+ ) {
361364 return id . id . length === 12 || ( id . id . length === 24 && checkForHexRegExp . test ( id . id ) ) ;
362365 }
363366
You can’t perform that action at this time.
0 commit comments