-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
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
| function _Url_percentEncode(string) | |
| { | |
| return encodeURIComponent(string); | |
| } | |
| function _Url_percentDecode(string) | |
| { | |
| try | |
| { | |
| return __Maybe_Just(decodeURIComponent(string)); | |
| } | |
| catch (e) | |
| { | |
| return __Maybe_Nothing; | |
| } | |
| } |
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.
Viir
Metadata
Metadata
Assignees
Labels
No labels