MCPcopy
hub / github.com/larksuite/cli / EncodePathSegment

Function EncodePathSegment

internal/validate/resource.go:60–62  ·  view source on GitHub ↗

EncodePathSegment percent-encodes user input for safe use as a single URL path segment (e.g. / → %2F, ? → %3F, # → %23), ensuring the value cannot alter the URL routing structure when interpolated into an API path. This provides defense-in-depth alongside ResourceName: ResourceName rejects known da

(s string)

Source from the content-addressed store, hash-verified

58// Convention: all user-provided variables in fmt.Sprintf API paths within shortcuts/
59// MUST be wrapped with this function.
60func EncodePathSegment(s string) string {
61 return url.PathEscape(s)
62}

Calls

no outgoing calls