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

Please expose extname #14

Description

@aMarCruz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions