Skip to content

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

Open
@fisker

Description

@fisker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.urlIssues and PRs related to the legacy built-in url module.

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions