basitalisandhu opened a new pull request, #574:
URL: https://github.com/apache/casbin-node-casbin/pull/574

   `keyMatch4` groups the captured values by token name, but the loop that 
checks repeated tokens then compares every captured value (`values`) with the 
first one instead of the values in that token's group (`value`), see 
`src/util/builtinOperators.ts` L226-233. So any pattern that has a repeated 
token plus at least one other token rejects valid paths:
   
   ```ts
   Util.keyMatch4Func('/parent/123/child/123/book/456', 
'/parent/{id}/child/{id}/book/{book_id}') // false, expected true
   Util.keyMatch4Func('/org/1/user/2/org/1', 
'/org/{org}/user/{user}/org/{org}')                 // false, expected true
   ```
   
   Go Casbin's `KeyMatch4` compares each token only with its own earlier value, 
and returns true for both.
   
   The fix compares the values within each token group. The new cases in 
`test/util.test.ts` fail before the change (expected true, received false) and 
pass after it, and the existing keyMatch4 cases still pass.
   
   Checked locally: `jest` (17 suites, 239 passed, conformance suite skipped), 
`eslint . --ext .js,.ts`, `pretty-quick`, and `npm run build`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to