urldecode
Available inall subroutines.
Decodes a percent-encoded string. For example, urldecode({"hello%20world+!"});
and urldecode("hello%2520world+!");
will both return "hello world !"
.
IMPORTANT: Although the input string may contain any percent-encoded data, the resulting output is treated as a string. As such, any NUL characters in the string will appear as a truncated result.
This function is not prefixed with the std.
namespace.
Example
set req.http.X-Cookie = regsub(req.url, ".*\?cookie=", "");set req.http.Cookie = urldecode(req.http.X-Cookie);
Try it out
urldecode
is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.
Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.
Validate domain on query string
Check the query string if it contains a valid domain.