Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Please expose extname #14

Closed
aMarCruz opened this issue Sep 22, 2016 · 2 comments
Closed

Please expose extname #14

aMarCruz opened this issue Sep 22, 2016 · 2 comments

Comments

@aMarCruz
Copy link

aMarCruz commented Sep 22, 2016

Hi team,
It is common practice to include an additional filter for extensions, exposing extname avoids dependency on node's path.

But the current extname behavior in pluginutils is different from the node version when the name starts or ends with a dot:

filename node pluginutils
.file '' '.file'
/.file '' '.file'
./.file '' '.file'
file. '.' ''
./file. '.' ''

this behave like in node, and do not depends in basename:

function extname ( path ) {
  const match = /(?!\.\/\\|\.\.)[^/\\](\.[^./\\]*)$/.exec( path );
  return match ? match[1] : '';
}

I can submit a PR if you wish.

@aMarCruz
Copy link
Author

oh, not an useful export, pluginutils depends on node's path anyway, so I think addExtension should use the node version.

@Rich-Harris
Copy link
Contributor

Thanks, sorry for slow response – this is fixed in 2.0.1 via 0e46f90

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants