unjs / pathe

🛣️ Drop-in replacement of the Node.js's path module module that ensures paths are normalized

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should pathe parse have the same return logic like node:path parse

prisis opened this issue · comments

Environment

Package Version: 1.1.2
Node: v21.7.1
OS: Windows (Tested)

Reproduction

Node path

path.parse(".\\dir\\file")  -> { 
  root: '',
  dir: '.\\dir',
  base: 'file',
  ext: '',
  name: 'file' 
}

path.parse("C:\\path\\dir\\file.txt")  -> {
    root: "C:/",
    dir: "C:/path/dir",
    base: "file.txt",
    ext: ".txt",
    name: "file",
  }

Pathe

parse(".\\dir\\file")  -> {
    root: ".",
    dir: "./dir",
    base: "file",
    ext: "",
    name: "file",
  }

parse("C:\\path\\dir\\file.txt") -> {
    root: "C:",
    dir: "C:/path/dir",
    base: "file.txt",
    ext: ".txt",
    name: "file",
  }

Describe the bug

Im expecting the same result like nodes path.parse but with normalize path

Additional context

Will adjust the PR based on the ticket comments how to handle the return value of root

Logs

No response