Availability
Helper Node Browser decodeURI✅ ✅ encodeURI✅ ✅ escape✅ — stripProtocol✅ — stripQuerystring✅ ✅ urlParse✅ — urlResolve✅ — url_decode✅ ✅ url_encode✅ ✅
Table of Contents
- {{encodeURI}}
- {{escape}}
- {{decodeURI}}
- {{url_encode}}
- {{url_decode}}
- {{urlResolve}}
- {{urlParse}}
- {{stripQuerystring}}
- {{stripProtocol}}
{{encodeURI}}
Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.
Params
str{String}: The un-encoded stringreturns{String}: The encoded string
Example
{{encodeURI "http://example.com?comment=Thyme &time=again"}}
<!-- results in: 'http%3A%2F%2Fexample.com%3Fcomment%3DThyme%20%26time%3Dagain' -->
{{escape}}
Escape the given string by replacing characters with escape sequences. Useful for allowing the string to be used in a URL, etc.
Params
str{String}returns{String}: Escaped string.
Example
{{escape "http://example.com?comment=Thyme &time=again"}}
<!-- results in: 'http%3A%2F%2Fexample.com%3Fcomment%3DThyme%20%26time%3Dagain' -->
{{decodeURI}}
Decode a Uniform Resource Identifier (URI) component.
Params
str{String}returns{String}
Example
{{decodeURI "http%3A%2F%2Fexample.com%3Fcomment%3DThyme%20%26time%3Dagain"}}
<!-- results in: 'http://example.com?comment=Thyme &time=again' -->
{{url_encode}}
Alias for encodeURI.
{{url_decode}}
Alias for decodeURI.
{{urlResolve}}
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.
Params
base{String}href{String}returns{String}
Example
{{urlResolve "/one/two/three" "four"}}
<!-- results in: '/one/two/four' -->
{{urlResolve "http://example.com/" "/one"}}
<!-- results in: 'http://example.com/one' -->
{{urlParse}}
Parses a url string into an object.
Params
str{String}: URL stringreturns{Object}: Returns parsed URL object
Example
{{urlParse "http://foo.com/bar/baz?key=value"}}
<!-- results in an object with: protocol: 'http:', hostname: 'foo.com', pathname: '/bar/baz', query: 'key=value' -->
{{stripQuerystring}}
Strip the query string from the given url.
Params
url{String}returns{String}: the url without the queryString
Example
{{stripQuerystring "http://example.com?tests=true"}}
<!-- results in: 'http://example.com' -->
{{stripProtocol}}
Strip protocol from a url. Useful for displaying media that may have an 'http' protocol on secure connections.
Params
str{String}returns{String}: the url with http protocol stripped
Example
{{stripProtocol "http://foo.bar"}}
<!-- results in: '//foo.bar/' -->