https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#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:
|
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.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#description
Url.percentDecodeis already wrapped in try-catch butUrl.percentEncodeisn’t:url/src/Elm/Kernel/Url.js
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
encodeURIComponentto 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.