MCPcopy
hub / github.com/apache/casbin / EscapeAssertion

Function EscapeAssertion

util/util.go:39–49  ·  view source on GitHub ↗

EscapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.

(s string)

Source from the content-addressed store, hash-verified

37
38// EscapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.
39func EscapeAssertion(s string) string {
40 s = escapeAssertionRegex.ReplaceAllStringFunc(s, func(m string) string {
41 // Replace only the last dot with underscore (preserve the prefix character)
42 lastDotIdx := strings.LastIndex(m, ".")
43 if lastDotIdx > 0 {
44 return m[:lastDotIdx] + "_"
45 }
46 return m
47 })
48 return s
49}
50
51// RemoveComments removes the comments starting with # in the text.
52func RemoveComments(s string) string {

Callers 6

TestABACTypesFunction · 0.92
enforceMethod · 0.92
generateEvalFunctionFunction · 0.92
AddDefMethod · 0.92
testEscapeAssertionFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestABACTypesFunction · 0.74
testEscapeAssertionFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…