-
Notifications
You must be signed in to change notification settings - Fork 30k
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
url: fix toPathIfFileUrl with string URL input #49466
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
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.
@AidanWelch thank you for pull request!
However, I don't think we can change this, see #48994 for reference.
To use URLs with node:fs
, user should pass URL object so it can be distinguished from path. For example, to read contents of directory where current file is located, use readdir(new URL('.', import.meta.url))
rather than readdir(new URL('.', import.meta.url).href)
.
If this looks unexpected, maybe you would want to update File URL paths part of documentation instead to explain it more clearly?
I think it is unexpected because |
Any API that uses |
How so? |
|
Functions using
toPathIfFileURL
(such asfs.readdir
) would have unexpected behavior when a string of a file URL was input such asimport.meta.url
,fileURLToPath
supports string input so there is no reason to not convert file URL strings.