Search code examples
javascriptsymbolshtml-escape-characters

Difference between : and :?


Can somebody tell me the difference between two in html. i was found this : in url but when i'm connecting with request in node js, the respond is ERR_UNESCAPED_CHARACTERS.

Which is confusing because symbols are like : (colon).

Is there a way to solve this?


Solution

  • You can use encodeURI to encode the special character. It assumes that the input is a complete URI that might have some characters which need encoding in it.

    encodeURI(url)

    This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters).

    Tip: Use the decodeURI() function to decode an encoded URI.