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(fslib): support utf8 buffers #4943

Merged
merged 1 commit into from
Oct 7, 2022
Merged

Conversation

paul-soporan
Copy link
Member

@paul-soporan paul-soporan commented Oct 6, 2022

What's the problem this PR addresses?

We don't support path Buffers in @yarnpkg/fslib.

Fixes #1818.

Supersedes:

How did you fix it?

Renamed URLFS to NodePathFS and implemented support for mapping Buffers to strings.

We currently only support valid utf8 buffers because binary buffers cannot be supported without keeping the paths as buffers until the end (see #4907 (comment)).

Because of this, we now throw an error when encountering buffers that cannot be encoded as utf8 and encourage users to upvote this issue so that we can gather how common non-utf8 buffers are.

The check uses Buffer.byteLength (credit to @arcanis for coming up with this idea) instead of Buffer.compare since the latter is quite slower.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Sorry, something went wrong.

@arcanis arcanis merged commit e3d5caa into master Oct 7, 2022
@arcanis arcanis deleted the paul/fix/support-utf8-buffers branch October 7, 2022 10:19
merceyz pushed a commit that referenced this pull request Nov 3, 2022
wrandall22 added a commit to CruGlobal/mpdx-react that referenced this pull request Apr 12, 2024
wrandall22 added a commit to CruGlobal/mpdx-react that referenced this pull request May 2, 2024
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.

[Bug] fs functions that use buffer encoding fail
3 participants