New array and map operation functions in Rulesets
Cloudflare Rulesets now includes four new functions (split, join, has_key, has_value) for advanced expression logic on arrays and maps, enabling use cases like country-based blocking with custom headers.
New functions for array and map operations
Cloudflare Rulesets now include new functions that enable advanced expression logic for evaluating arrays and maps. These functions allow you to build rules that match against lists of values in request or response headers, enabling use cases like country-based blocking using custom headers.
New functions
| Function | Description |
|---|---|
split(source, delimiter) |
Splits a string into an array of strings using the specified delimiter. |
join(array, delimiter) |
Joins an array of strings into a single string using the specified delimiter. |
has_key(map, key) |
Returns true if the specified key exists in the map. |
has_value(map, value) |
Returns true if the specified value exists in the map. |
Example use cases
Check if a country code exists in a header list:
has_value(split(http.response.headers["x-allow-country"][0], ","), ip.src.country)
Check if a specific header key exists:
has_key(http.request.headers, "x-custom-header")
Join array values for logging or comparison:
join(http.request.headers.names, ", ")
For more information, refer to the Functions reference.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare One Client for Windows hotfix - trusted certificate chains
A new GA release for Windows Cloudflare One Client is available, addressing an issue with building trusted certificate chains.
Cloudflare One Client for macOS - Trusted Certificate Chain Fix
A new GA release of the macOS Cloudflare One Client is available. This hotfix addresses an issue with building trusted certificate chains.
Cloudflare One Client for Linux
A new GA release of Cloudflare One Client for Linux is now available. This hotfix addresses an issue with building trusted certificate chains.