The encodeURI()
function does not encode characters that have special meaning (reserved characters) for a URI. The following example shows all the parts that a URI "scheme" can possibly contain. Note how certain characters are used to signify special meaning:
http://username:[email protected]:80/path/to/file.php?foo=316&bar=this+has+spaces#anchor
Hence encodeURI()
does not encode characters that are necessary to formulate a complete URI. Also, encodeURI()
does not encode a few additional characters, known as "unreserved marks", which do not have a reserved purpose but are allowed in a URI "as is". (See RFC2396)
encodeURI()
escapes all characters except:
Not Escaped:
A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #