-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(fslib): path buffer and file url support #1584
Conversation
d155791
to
d53018e
Compare
protected mapFromBase(path: PathLike<PortablePath>) { | ||
return npath.fromPortablePath(ppath.fromPathLike(path)); | ||
} | ||
|
||
protected mapToBase(path: NativePath) { | ||
return npath.toPortablePath(path); | ||
protected mapToBase(path: PathLike<NativePath>) { | ||
return npath.toPortablePath(npath.fromPathLike(path)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, shouldn't we return the same type of PathLike
as the one we receive? As we saw, the result of Buffer.from(Buffer.from([0xca, 0xc5, 0x0e]).toString('binary'), 'binary')
is correct while the result of Buffer.from(Buffer.from([0xca, 0xc5, 0x0e]).toString('binary'))
isn't. That means that the string representation would break if definitely turned into a string, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be safer to include tests that use [0xca, 0xc5, 0x0e]
to be sure that we handle this tricky case properly.
…ffer-and-url-support
…ffer-and-url-support
Getting the buffer part to work is a bit of a nightmare, would be possible to split this to get URL support first which seems to be working |
I'll rebase (this will be fun) and remove the buffer part until I manage to get it working. The last time I tested it, the URL part worked without any catches. |
What's the problem this PR addresses?
FakeFS
doesn't currently support Path Buffers and File URLs, unlike Node's built-infs
.Fixes #899, fixes #1818.
How did you fix it?
I added support for Path Buffers and File URLs. I made it type-safe by adding specific Portable / Native variants of Path Buffers and File URLs. I also exposed the converters onto
PathUtils
. I also added tests.Checklist