-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
URL version of process.cwd() #49273
Copy link
Copy link
Closed as not planned
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.stalewhatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.stalewhatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
What is the problem this feature will solve?
Right now we don't have convenient way to get current working directory in URL form such as
file:///path/to/current/working/directory/.Having easy access to this form would allow to resolve local paths using WHATWG URL constructor, i.e.
new URL('../path/to/file', cwdURL), without need to importpathand worry about platform-specific separators.Getting this form in userspace is not very convenient:
What is the feature you are proposing to solve the problem?
URLinstances withfile:protocol inprocess.chdir(directory).process.cwdURL()that returnsURLinstance or string.resolve(...urls)method that would construct new absolute URL on top of cwd if all providedurlsare relative.url.resolve()is not vacant and has different behaviour, so it should have different name or place.Better naming suggestions are very welcome.
What alternatives have you considered?
file:protocol that would resolve relativepathnameagainst cwd instead of root, i.e.: