decodeURI() | javascript urldecode
decodeURI()isafunctionpropertyoftheglobalobject.ThedecodeURI()functiondecodestheURIbytreatingeachescapesequenceintheform%XXasoneUTF-8codeunit(onebyte).InUTF-8,thenumberofleading1bitsinthefirstbyte,whichmaybe0(for1-byteASCIIcharacters),2,3,or4,indicatesthenumberofbytesinthecharacter.Sobyreadingthefirstescapesequence,decodeURI()candeterminehowmanymoreescapesequencestoconsume.IfdecodeURI()failstofindtheexpectednumberofsequences,oriftheescapesequencesdontencodeavalidUTF-8character,aURIError[1]is...
decodeURI() is a function property of the global object.
The decodeURI() function decodes the URI by treating each escape sequence in the form %XX as one UTF-8 code unit (one byte). In UTF-8, the number of leading 1 bits in the first byte, which may be 0 (for 1-byte ASCII characters), 2, 3, or 4, indicates the number of bytes in the character. So by reading the first escape sequence, decodeURI() can determine how many more escape sequences to consume. If decodeURI() fails to find the expected number of sequences, or if the escape sequences dont encode a valid UTF-8 character, a URIError[1] is thrown.
decodeURI() decodes all escape sequences, but if the escape sequence encodes one of the following characters, the escape sequence is preserved in the output string (because they are part of the URI syntax):
; / ? : @ & = + $ , # References URIError (developer.mozilla.org)