The order of validation / errors
zloirock opened this issue · 2 comments
zloirock commented
Let's take a look, for example, at the errors order in Uint8Array.fromBase64 at string parsing:
Sure, all of those errors are SyntaxError, but for better debugging, it seems in implementations they will have different error messages. And here we have 2 problems:
- It will cause problems for parsing in 1 pass
- The order of error is strange - for example, in case of the string with wrong length and symbols with another encoding (
+-\_), withbase64encoding we will have the error with length, withbase64url- with wrong symbols
bakkot commented
Because the spec does not specify messages, from the point of view of the spec any choice of ordering is legal. There's a NOTE about this in the spec:
- NOTE: The order of validation and decoding in the algorithm below is not observable. Implementations are encouraged to perform them in whatever order is most efficient, possibly interleaving validation and stripping whitespace with decoding, as long as the behaviour is observably equivalent.
zloirock commented
Ok, let it be -) I thought that this note did not apply to the entire subsequent algorithm.
