nodejs / nodejs/node

Add a utility to convert file URL or path to one of them?

Open
#41,521 41 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request never-stale url
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

It's a nice way to accept both URL and path string in API, but we need covert it to either string or URL, it would be nice to have a built-in method to do this.

What is the feature you are proposing to solve the problem?

For converting to string:

Maybe add path.from(URL | string)? @sindresorhus proposed here.

For converting to URL:

url.from(URL | string)

I'm not sure, since URL is a standard, I guess adding method URL object won't be acceptable, maybe to node:url module?

What alternatives have you considered?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed path.from(URL | string) and url.from(URL | string) APIs, along with the node:url module mentioned in the issue. Determine which conversion semantics and module ownership are appropriate; the work is done when one API shape and its behavior are clearly specified and implemented with corresponding coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.