Repository navigation
Conversation
stringPercentDecode() UTF-8 encodes its input into a fresh Uint8Array and then percent-decodes it into a second array of the same size. After URL parsing, a data: URL body contains '%' only when it has non-ASCII or control characters or explicit escapes, so plain-text and base64 bodies were copied byte-for-byte for nothing. Return the encoded bytes directly when the input contains no '%'. UTF-8 never emits 0x25 inside a multi-byte sequence, so the result is identical, and each call still returns its own buffer. When there is a '%', pass its index to percentDecode(), which copies a long unescaped prefix in bulk and decodes the rest through subarray views, so the loop still starts at 0 and keeps its bounds checks eliminated. The string index is used only when every code point encoded to a single byte, so it is also the byte index. Signed-off-by: Yaroslav Chuhai <yaroslavchuhai@gmail.com>
Collaborator
|
Review requested:
|
Contributor
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67684 +/- ##
==========================================
- Coverage 90.71% 90.60% -0.12%
==========================================
Files 801 801
Lines 280917 281107 +190
Branches 54237 54269 +32
==========================================
- Hits 254832 254691 -141
- Misses 16253 16601 +348
+ Partials 9832 9815 -17
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decoding a
data:URL body copied every byte into a second array, even when there was nothing to decode. Skip when there's nothing, and take the index when there is a percent and use that to start the encoding.benchmark/esm/data-url-processor.js(30 runs):plainbase64percentpercent-tailpercent-midpercent-at-64