url: fix toPathIfFileUrl with string URL input#49466
url: fix toPathIfFileUrl with string URL input#49466AidanWelch wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
LiviaMedeiros
left a comment
There was a problem hiding this comment.
@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,fileURLToPathsupports string input so there is no reason to not convert file URL strings.