Skip to content

Commit 0f1629e

Browse files
author
Jonas Meier
committed
Fix cache for string IDs that have exactly 12 bytes
* The method `isValid` from MongoDB just checks if a string has 12 bytes. But you could have a string ID which length=12 which would be unintentionally converted to an ObjectID which in returns causes an invalid cache miss.
1 parent 6e09fe8 commit 0f1629e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const stringToId = str => {
1010
return str
1111
}
1212

13-
if (ObjectId.isValid(str)) {
13+
if (ObjectId.isValid(str) && new ObjectId(str) === str) {
1414
return new ObjectId(str)
1515
}
1616

0 commit comments

Comments
 (0)