Skip to content

Commit c39d4c5

Browse files
committed
perf
1 parent b8a18eb commit c39d4c5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

base64.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function fromBase64url(str, format = 'uint8') {
5151

5252
// These checks should be needed only for Buffer path, not Uint8Array.fromBase64 path, but JSC lacks proper checks
5353
assert(str.length % 4 !== 1, 'Invalid base64 length') // JSC misses this in fromBase64
54-
assert(!str.includes('='), 'Did not expect padding in base64url input')
54+
assert(!str.endsWith('='), 'Did not expect padding in base64url input') // inclusion is checked separately
5555

5656
return fromTypedArray(fromBase64common(str, true), format)
5757
}
@@ -80,7 +80,7 @@ if (Uint8Array.fromBase64) {
8080
arr = new Uint8Array(raw.length)
8181
for (let i = 0; i < raw.length; i++) arr[i] = raw.charCodeAt(i)
8282
} else {
83-
// base64url is already checked to have no padding
83+
// base64url is already checked to have no padding via a regex above
8484
if (!isBase64url) assert(!str.includes('=') || !/=[^=]/iu.test(str), 'Invalid padding')
8585
arr = haveNativeBuffer ? Buffer.from(str, 'base64') : fromBase64js(str)
8686
}

0 commit comments

Comments
 (0)