Open In App
Related Articles

JavaScript URIError | Malformed URI Sequence

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

This JavaScript exception malformed URI sequence occurs if the encoding or decoding of URI is unsuccessful.

Message:

URIError: The URI to be encoded contains invalid character (Edge)
URIError: malformed URI sequence (Firefox)
URIError: URI malformed (Chrome)

Error Type:

URIError

Cause of the Error: This error is thrown as somewhere in the code, the URI encoding or decoding is unsuccessful.

Example 1: In this example, the value passed is not acceptable, therefore the error has occurred.

Javascript

// Error here
encodeURI('\uD810');

                    

Output:

URIError: URI malformed

Example 2: In this example, the value passed is not acceptable, therefore the error has occurred.

Javascript

// Error here
decodeURIComponent('%E0%B4%A');

                    

Output:

URIError: URI malformed

Last Updated : 22 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads