Skip to content

filename fails when file does not have extension and the path contains a period #184

@cjpearson

Description

@cjpearson

Environment

Node 20.17.0, pathe 1.1.2

Reproduction

const { filename } = require("pathe/utils") 
console.log(filename('/Users/connor/foo/bar')) // 'bar' ✅ 
console.log(filename('/Users/connor.pearson/foo/bar.js')) // 'bar' ✅ 
console.log(filename('/Users/connor.pearson/foo/bar')) // 'connor' ❌ (Expected 'bar')

Describe the bug

When given a path where the file does not have an extension, and an ancestor directory contains a period, the filename function returns the first segment of the ancestor directory rather than the file.

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions