Skip to content

feat: add keyGet3 function#522

Merged
hsluoyz merged 1 commit into
apache:masterfrom
AlabLan:keyget3
Jun 16, 2026
Merged

feat: add keyGet3 function#522
hsluoyz merged 1 commit into
apache:masterfrom
AlabLan:keyget3

Conversation

@AlabLan

@AlabLan AlabLan commented May 14, 2026

Copy link
Copy Markdown
Contributor

fix: #523

Summary

Added the keyGet3 function to jcasbin for the {var} placeholder style, which was previously only available in the Go version.

Problem

The documentation at https://casbin.apache.org/docs/function shows keyGet3 function, but jcasbin only implemented keyGet and keyGet2.

Implementation

  • Added KeyGet3Func wrapper class
  • Added keyGet3Func implementation in BuiltInFunctions
  • Registered keyGet3 in FunctionMap
  • Added comprehensive tests ported from Go's TestKeyGet3

Note on Go/Java Regex Incompatibility

The following Go test cases fail in Java due to regex engine differences:

  • testKeyGet3("/{id/using/myresid", "/{id/using/{resId}", "resId", "myresid")
  • testKeyGet3("/{id/using/myresid/status}", "/{id/using/{resId}/status}", "resId", "myresid")
  • testKeyGet3("/api/group1_group_name/project1_admin/info", "/api/{proj}_admin/info", "proj", "")

Java treats { as a repetition quantifier modifier, so patterns like "/{id/using/(" are invalid. The Java implementation adds escaping for remaining { and } characters after the key replacement to
handle this incompatibility.

@AlabLan AlabLan changed the title bugfix: add keyGet3 function for {var} placeholder style fix: add keyGet3 function May 15, 2026
@hsluoyz hsluoyz changed the title fix: add keyGet3 function feat: add keyGet3 function Jun 16, 2026
@hsluoyz hsluoyz merged commit 62afab5 into apache:master Jun 16, 2026
4 checks passed
hsluoyz pushed a commit that referenced this pull request Jun 16, 2026
@AlabLan AlabLan deleted the keyget3 branch June 22, 2026 06:19
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.

keyGet3 function not implemented in jcasbin

2 participants