Skip to content

path.basename accepts ext as any string to remove #44773

Closed
@connorjburton

Description

@connorjburton

Version

18.6.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

No response

What steps will reproduce the bug?

import assert from 'node:assert/strict';
import path from 'path';

assert.deepEqual(path.basename('somerandomchars', 'chars'), 'somerandom');

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Should not accept a non extension string as the ext parameter.

What do you see instead?

I can use path.basename as a generic end of string removal function.

path.basename('somerandomchars', 'chars') removes chars from my path

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    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