Url.percentEncode can throw errors
lydell opened this issue · 0 comments
lydell commented
Note that a URIError will be thrown if one attempts to encode a surrogate which is not part of a high-low pair
> import Url
> Url.percentEncode "\u{d800}"
URIError: URI malformed
Url.percentDecode
is already wrapped in try-catch but Url.percentEncode
isn’t:
Lines 7 to 22 in 4e5ee03
Note: I have never encountered this for real. I just noticed this because I went to the MDN page for encodeURIComponent
to better learn how it works, and realized this is another way an exception can be thrown in Elm. So I’m reporting this more for documentation and collecting all the weird edge cases.