fix(ext/node): allow omitting arguments in base64Slice#34318
Conversation
fibibot
left a comment
There was a problem hiding this comment.
Defaulting offset and length in Buffer.prototype.base64Slice fixes the direct call path that previously passed undefined/NaN into op_base64_encode_from_buffer; Buffer#toString("base64") still uses its existing normalized start/end dispatch. The added unit test covers the omitted-argument regression. Holding approval until CI is green.
|
|
fibibot
left a comment
There was a problem hiding this comment.
CI is green now, promoting prior review to APPROVE.
|
@bartlomieju this is ready to merge |
lunadogbot
left a comment
There was a problem hiding this comment.
Defaulting offset and length only when they are undefined preserves explicit-range calls while fixing buf.base64Slice() and buf.base64Slice(0, 3), which previously sent undefined/NaN into op_base64_encode_from_buffer. The unit coverage hits the omitted-argument path for both base64 and base64url, and CI is green.
|
@bartlomieju this is ready to merge |
Closes #34286
Summary
The
offsetandlengthparameters are optional and default to0andbuffer.length(), respectively, as defined in node source code. This PR adds default values to these parameters to match Node.js behavior.Followed @bddjr recommendations.