Skip to content

path.format should accept a file extension without a leading dot #44343

Description

@sindresorhus

What is the problem this feature will solve?

Some (user-land) APIs return a file extension without the dot.

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

It would be nice if path.format() would handle file extension without the leading dot.

Current behavior:

path.format({name: 'x', ext: 'png'});
//=> 'xpng'

Wanted behavior:

path.format({name: 'x', ext: 'png'});
//=> 'x.png'

The current behavior makes no sense and should at minimum have caused an error.

So what I'm requested is that if the ext is missing a leading dot, it would be added.

What alternatives have you considered?

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.pathIssues and PRs related to the path subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions