Open JeromeA opened 7 years ago
Sadly, normalize doesn't work for data URIs (maybe it should, but currently it doesn't).
As I read RFC 4648, padding can be omitted when the data length is known, and I guess that's always the case for data URIs, so it seems like a reasonable feature to have.
Why do you mean be "normalize doesn't work"?
BASE64URL.decode(BASE64URL.normalize('AA')) correctly returns [0].
Ah, my bad, I was confusing it with Uri.normalize
.
RFC4648, chapter 5, states in the description of Base64Url that the padding can be skipped.
BASE64URL.decode('AA') raises an exception ("FormatException: Invalid length, must be multiple of four (at character 3)"), when it should return [0], as the padding in 'AA==' is optional.
This could either be fixed in the code (my preference), or in the comments, by saying that contrary to the rfc specifications, this implementation requires padding, and that the user should call the normalize() method before decode() if the padding can be missing.