STRING::ESCAPE_PATH
1g 2023-11-12 laplante@plcb.ca GOWEB/STRING — Escape Strings for URL Pathstitle: “STRING::ESCAPE_PATH” version: “1.0.0” date: 2023-11-12 author: “laplante@plcb.ca” section: “1g” category: “GOWEB/STRING”
string::escape_path Escape Strings for URL Paths
string::escape_path(string)
escape_path(string)
string::escapePath(string)
escapePath(string)
The escape_path
function encodes a string so it can be safely included as a segment of a URL path.
Characters that are not valid in a URL path segment are replaced with their percent-encoded equivalents.
Key details:
" "
) are encoded as %!<(MISSING)/code>.
"/"
) and other reserved characters are also encoded (%!F(MISSING)
, etc.).This is particularly useful when inserting dynamic values into a URL:
https://localhost?files={{ escape_path(files) }}
escape_path
and escape_uri
escape_path
Escapes a string for use in the URL path segment. Encodes characters such as spaces, slashes, and special characters.
escape_uri
Escapes a string for use as a query parameter value in a URL. Encodes characters such as spaces, ampersands, and other query-specific reserved characters.
res={{
a := { "array" : [1,2,3] };
escape_path(a);
escape_path("A long string");
}};
Returns:
res = %!B(MISSING)%!a(MISSING)rray%3A%!B(MISSING)1%!C(MISSING)2%!C(MISSING)3%!D(MISSING)%!D(MISSING)A%!l(MISSING)ong%!s(MISSING)tring