Articles in this section

stripProtocol helper

The stripProtocol helper removes the protocol prefix (e.g. http://, https://) from a URL and returns a protocol-relative path. Use it when links need to work correctly across environments where the protocol may vary.

Syntax

{{stripProtocol url}}

url -- The URL string to process. Required.

Examples

Remove the protocol from a URL

{{stripProtocol record.cdn}}

Input:

{ "record": { "cdn": "http://foo.bar/image.png" } }

Output: //foo.bar/image.png

Usage notes

  • The domain, path, and query parameters are preserved -- only the protocol prefix is removed.
  • Values that are already protocol-relative (e.g. //example.com/...) are returned unchanged.
  • Only the first protocol occurrence is removed. In a URL such as https://example.com/redirect?url=http://other.com, only the leading https:// is stripped -- the http:// inside the query string remains.
  • Scheme matching is case-insensitive and supports http, https, ftp, ws, and h2.
  • To also remove query parameters from the URL, combine with the stripQuerystring helper.