Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: accepts uppercase values in mongoose.isValidObjectId #10846

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

foxadb
Copy link
Contributor

@foxadb foxadb commented Oct 5, 2021

Summary

ObjectId are case-insensitives in MongoDB as long as the value is hexadecimal.

mongoose.isValidObjectId function should consider uppercase ObjectId as valid.

Example

Adding the two following assertions to the test suite:

assert.ok(mongoose.isValidObjectId('5f5c2d56f6e911019ec2acdc')); // passing before and after change
assert.ok(mongoose.isValidObjectId('608DE01F32B6A93BBA314159')); // passing only after change

ObjectId are case-insensitives in MongoDB as long as the value is hexadecimal.
mongoose.isValidObjectId function should consider uppercase ObjectId as valid.
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@vkarpov15 vkarpov15 merged commit f0fb8a2 into Automattic:master Oct 6, 2021
@vkarpov15 vkarpov15 added this to the 6.0.10 milestone Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants