-
Notifications
You must be signed in to change notification settings - Fork 90
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: make schema path de-resolution utility more robust #685
Conversation
for (const pathSegment of path.split('.')) { | ||
const pathSegments = path.split('.'); | ||
|
||
for (let i = 0; i < pathSegments.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only real change is that now we use a numerically-indexed for-loop so that we know for sure when we're going through it for the last time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing I could find was that the copyright year should be updated.
Before, the check used faulty logic to determine if we were on the last iteration through a loop. This could lead to unintended behavior in rare cases. This clarifies the logic to only execute the last time through the loop and for no other reason (the potential reason being if the last path segment matched an earlier path segment). Signed-off-by: Dustin Popp <dpopp07@gmail.com>
b02761f
to
812c6ba
Compare
Good catch! Fixed |
## @ibm-cloud/openapi-ruleset [1.23.1](https://github.com/IBM/openapi-validator/compare/@ibm-cloud/openapi-ruleset@1.23.0...@ibm-cloud/openapi-ruleset@1.23.1) (2024-09-25) ### Bug Fixes * make schema path de-resolution utility more robust ([#685](#685)) ([b25b840](b25b840))
🎉 This PR is included in version 1.23.1 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.24.1 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.5.0 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
Before, the check used faulty logic to determine if we were on the last iteration through a loop. This could lead to unintended behavior in rare cases. This clarifies the logic to only execute the last time through the loop and for no other reason (the potential reason being if the last path segment matched an earlier path segment).