Version
v20.18.0
Platform
Microsoft Windows NT 10.0.22631.0 x64
Subsystem
No response
What steps will reproduce the bug?
When attempting to create an ArrayBuffer using Buffer.from(..., 'base64url').buffer, the output is incorrect. Instead of the expected ArrayBuffer, the function produces an unexpectedly larger ArrayBuffer.
node -p "Buffer.from('G4Zmayf9a4KOkKHBFeHHQREzRMW_6MPR', 'base64url').buffer"
Result:
ArrayBuffer {
[Uint8Contents]: <5c 00 00 00 00 00 00 00 1b 86 66 6b 27 fd 6b 82 8e 90 a1 c1 15 e1 c7 41 11 33 44 c5 bf e8 c3 d1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 8092 more bytes>,
byteLength: 8192
}
FYI: The string G4Zmayf9a4KOkKHBFeHHQREzRMW_6MPR is produced by Buffer#toString('base64url') containing some random bytes.
How often does it reproduce? Is there a required condition?
Stable
What is the expected behavior? Why is that the expected behavior?
Should get a correctly-sized ArrayBuffer representing the base64url decoded string, like Deno does:
deno eval "import { Buffer } from 'node:buffer';
console.log(Buffer.from('G4Zmayf9a4KOkKHBFeHHQREzRMW_6MPR', 'base64url').buffer)"
ArrayBuffer {
[Uint8Contents]: <1b 86 66 6b 27 fd 6b 82 8e 90 a1 c1 15 e1 c7 41 11 33 44 c5 bf e8 c3 d1>,
byteLength: 24
}
What do you see instead?
ArrayBuffer {
[Uint8Contents]: <5c 00 00 00 00 00 00 00 1b 86 66 6b 27 fd 6b 82 8e 90 a1 c1 15 e1 c7 41 11 33 44 c5 bf e8 c3 d1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 8092 more bytes>,
byteLength: 8192
}
Additional information
No response
Version
v20.18.0
Platform
Subsystem
No response
What steps will reproduce the bug?
When attempting to create an
ArrayBufferusingBuffer.from(..., 'base64url').buffer, the output is incorrect. Instead of the expectedArrayBuffer, the function produces an unexpectedly largerArrayBuffer.node -p "Buffer.from('G4Zmayf9a4KOkKHBFeHHQREzRMW_6MPR', 'base64url').buffer"Result:
FYI: The string
G4Zmayf9a4KOkKHBFeHHQREzRMW_6MPRis produced byBuffer#toString('base64url')containing some random bytes.How often does it reproduce? Is there a required condition?
Stable
What is the expected behavior? Why is that the expected behavior?
Should get a correctly-sized
ArrayBufferrepresenting thebase64urldecoded string, like Deno does:What do you see instead?
Additional information
No response