Repository navigation
fix: compare repeated keyMatch4 tokens only with their own values - #574
Merged
hsluoyz merged 1 commit intoOct 27, 2026
Merged
Conversation
keyMatch4 grouped the captured values by token name, but the check for a
repeated token then compared every captured value with the first one. Any
pattern with a repeated token plus another token rejected valid paths, for
example /parent/123/child/123/book/456 against
/parent/{id}/child/{id}/book/{book_id}. Compare the values within each
token group instead, as Go Casbin does.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #574 +/- ##
=========================================
Coverage ? 71.30%
=========================================
Files ? 34
Lines ? 2206
Branches ? 517
=========================================
Hits ? 1573
Misses ? 381
Partials ? 252
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
keyMatch4groups captured values by token name, but the repeated-token loop compares every captured value (values) with the first one instead of that token's own group (value), seesrc/util/builtinOperators.tsL226-233. So a pattern with a repeated token plus any other token rejects valid paths:Go Casbin's
KeyMatch4compares each token only with its own earlier value and returns true for both.Now values are compared within each token group. The new cases in
test/util.test.tsfail before (expected true, received false) and pass after; existing keyMatch4 cases still pass.jest(17 suites, 239 passed, conformance skipped),eslint . --ext .js,.ts,pretty-quickandnpm run buildare clean.