Skip to content

doc: clarify fs string paths are not parsed as URLs#64531

Open
soreavis wants to merge 1 commit into
nodejs:mainfrom
soreavis:doc-fs-string-paths
Open

doc: clarify fs string paths are not parsed as URLs#64531
soreavis wants to merge 1 commit into
nodejs:mainfrom
soreavis:doc-fs-string-paths

Conversation

@soreavis

Copy link
Copy Markdown

The String paths section doesn't mention that a string beginning with file: is treated as a literal path, not parsed as a URL — the confusion in #36585, where maintainers invited a clarifying addition. This adds one paragraph stating the behavior, what actually happens on POSIX, and points to URL objects for file: URL support. Verified against getValidatedPath/toPathIfFileURL (strings are never URL-parsed anywhere in node:fs) and by running the file: directory repro from the issue on current main. I used an AI assistant while researching and drafting this change; I've verified the behavior and the wording against the source myself and take full responsibility for it.

Fixes: #36585

The String paths section does not say that a string beginning with
file: is treated as a literal path rather than a file: URL, which
regularly surprises users. State it explicitly and point to URL
objects for file: URL support.

Fixes: nodejs#36585
Signed-off-by: Julian Soreavis <julian.soreavis@gmail.com>
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Jul 16, 2026
@CxRes

CxRes commented Jul 16, 2026

Copy link
Copy Markdown

Thanks for suggesting the fix! This was so long ago that I had forgotten about it.

My concern is that describing the behaviour in the notes means that a reader is still likely to miss it. Ideally the <string> should link to the note, perhaps through a footnote. But I understand that would require a more involved change to the documentation.

But I would suggest merging this as a first step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc: Clarify what <string> means in path option of fs.readFile, fs.readFileSync etc.

3 participants