Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sindresorhus opened this issue Aug 22, 2022 · 1 comment · Fixed by #44349
Closed

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

sindresorhus opened this issue Aug 22, 2022 · 1 comment · Fixed by #44349
Labels
feature request Issues that request new features to be added to Node.js. path Issues and PRs related to the path subsystem.

Comments

@sindresorhus
Copy link

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

@sindresorhus sindresorhus added the feature request Issues that request new features to be added to Node.js. label Aug 22, 2022
@VoltrexKeyva VoltrexKeyva added the path Issues and PRs related to the path subsystem. label Aug 22, 2022
@tniessen
Copy link
Member

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

I tend to agree, but some application might rely on the current behavior (see #44349 (comment)).

nodejs-github-bot pushed a commit that referenced this issue Oct 10, 2022
PR-URL: #44349
Fixes: #44343
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. path Issues and PRs related to the path subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants