Removes the protocol (http://, https://, etc.) from a URL, returning a protocol-relative path.
-
Remove protocol from a CDN URL
{{stripProtocol record.cdn}}Input:
{ "record": { "cdn": "http://foo.bar/image.png" } }Output:
//foo.bar/image.png
Tip
-
Useful for ensuring links work correctly across environments where protocol may vary.
-
The helper preserves the rest of the URL, including domain, path, and query parameters.
-
Combine with
stripQuerystringif you also want to remove query parameters while keeping the domain and path. -
Values that are already protocol-relative (
//example.com/...) remain unchanged (no duplicate forwardslashes). -
Only the first occurrence of
<scheme>://is removed. For example,https://example.com/redirect?url=http://other.com, only the leading https is removed; thehttp://inside the query remains. -
Scheme matching is case-insensitive and can handle HTTP(S). FTP, WS, and
h2://.