How to use reserved characters in a URI

If you have to encode a reserved character (such as ‘/’ or ‘@’) so that it can be passed in a URI path, you may need to encode it twice:


const ticker = '@SMC/2018',
	encodedTicker = encodeURIComponent(encodeURIComponent(ticker)),
	uri = `${encodedTicker}/load`;

See also: “When to Encode or Decode” if you like to be confused.

Leave a Reply

Your email address will not be published. Required fields are marked *