For AI agents: the complete documentation index is available at /hclapi/llms.txt, the full documentation bundle is available at /hclapi/llms-full.txt, and this page is available as Markdown at /hclapi/docs/manifest/functions/strings/trim_suffix.md.

trim_suffix

Removes a suffix from the end of a string if present.

Signature

trim_suffix(str: string, suffix: string) -> string

Parameters

ParameterTypeRequiredDescription
str, suffixstring, stringyesInput string and suffix

Return value

Returns the documented result for the function signature.

Example

respond { status = 200, body = { file = trim_suffix(ctx.request.query.file, ".json") } }