std.strstr

STRINGstd.strstrSTRINGhaystackSTRINGneedle

Available inall subroutines.

Returns the part of haystack string starting from and including the first occurrence of needle until the end of haystack.

Example

set req.http.X-qs = std.strstr(req.url, "?");

Try it out

std.strstr 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.

Detect leaked passwords

Detect requests that contain submitted passwords and use a service to determine whether the password has leaked before allowing the request to proceed to origin (data from haveibeenpwned).

Compute intersection of two lists

Useful for comparing capabilities with required permissions.

Prevent hotlinking of product images by third-party websites

Detect and reject requests from third-party websites that attempt to embed your images on their pages.