Home > OS >  How to test invalid input for encodeURIComponent()
How to test invalid input for encodeURIComponent()

Time:01-25

How to write invalid input for encodeURIComponent()?

I browsed the documentation for encodeURIComponent. It mentions

URIError: Thrown if uriComponent contains a lone surrogate.

How to test this while writing a unit test?

CodePudding user response:

You can try an invalid unicode symbol. Something like this: encodeURIComponent('\uDFFF');

  • Related