Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blob): Add the current offset to the new blob slice #6259

Merged
merged 1 commit into from
Oct 3, 2023

Conversation

Hanaasagi
Copy link
Collaborator

What does this PR do?

Close: #6252

const blob = new Blob(["0123456789"]);
console.log(await blob.slice(2, 8).slice(0, 3).text());
// Output:
// node: 234
// bun: 012

offset is overwritten by relativeStart, causing blob.slice().slice() to always use the parameters from the last slice call. This Add the current offset to the new blob slice.

var blob = this.dupe();
blob.offset = @as(SizeType, @intCast(relativeStart));
blob.size = len;

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

I wrote automated tests

  • I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be
  • I or my editor ran zig fmt on the changed files
  • I included a test for the new code, or an existing test covers it
  • JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed

@Electroid
Copy link
Contributor

Tests pass, thanks!

@Electroid Electroid merged commit b7982ac into oven-sh:main Oct 3, 2023
15 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The offset of Blob.slice.slice is incorrect
2 participants