std.prefixof

BOOLstd.prefixofSTRINGsSTRINGbegins_with

Available in all subroutines.

True if the string s begins with the string begins_with. An empty string is not considered a prefix.

Returns false otherwise.

Example

set req.http.X-ps = std.prefixof("greenhouse", "green");

Try it out

std.prefixof is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

JSON web tokens

Decode the popular JWT format to verify user session tokens before forwarding trusted authentication data to your origin.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.