Rules - Remove surrounding bytes with trim functions
- Announced
- Tags
- Rules
- Severity
- info, set by
reef/rss-rule-v1 - Source
- https://developers.cloudflare.com/changelog/post/2026-10-14-trim-functions/
<p>Cloudflare Rules supports three new functions for removing surrounding bytes. Use them to remove whitespace before comparing request values. All HTTP products support these functions on all plans:</p> <ul> <li><code>trim()</code> removes bytes from both ends.</li> <li><code>trim_start()</code> removes bytes from the start.</li> <li><code>trim_end()</code> removes bytes from the end.</li> </ul> <p>By default, these functions remove ASCII whitespace. An optional constant string specifies a custom set of bytes.</p> <p>If the input value is nil, these functions return nil.</p> <p>For example, this expression removes surrounding whitespace before comparing a header value:</p> <figure class="nb-code-figure" data-nb-lang="txt"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="txt" data-nb-lang="txt"><code><span class="line"><span class="nb-shiki-wvjl67">trim(http.request.headers["x-label"][0]) eq "approved"</span></span></code></pre></figure> <p>For details, refer to the <a href="https://developers.cloudflare.com/ruleset-engine/rules-language/functions/#trim"><code>trim()</code></a>, <a href="https://developers.cloudflare.com/ruleset-engine/rules-language/functions/#trim_start"><code>trim_start()</code></a>, and <a href="https://developers.cloudflare.com/ruleset-engine/rules-language/functions/#trim_end"><code>trim_end()</code></a> function references.</p>
The text above is the source's. reef added the severity, the dates it could read from the text, and the endpoints and scopes named in code.