Skip to content

fix(parse)!: fix root handling to be consistent with node#194

Merged
pi0 merged 5 commits intomainfrom
fix-parse
Dec 30, 2024
Merged

fix(parse)!: fix root handling to be consistent with node#194
pi0 merged 5 commits intomainfrom
fix-parse

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Dec 30, 2024

resolves #167

Rework of #168 by @prisis

root in parse result should be strictly either / or X:/ (as per node util docs)

This PR:

  • Removes . fallback for posix paths
  • Adds trailing / to win32 paths

image
import path from 'node:path'
import pathe from 'pathe'

console.log('Node version: ' + process.version + "\n");

for (const p of [".\\dir\\file", "C:\\path\\dir\\file.txt"]) {
  console.log(p);
  console.log("   path  (posix)  : ", JSON.stringify(path.posix.parse(p)));
  console.log("   path  (win32)  : ", JSON.stringify(path.win32.parse(p)));
  console.log("   pathe (new)    : ", JSON.stringify(pathe.parse(p)));
  console.log();
}

@pi0 pi0 mentioned this pull request Dec 30, 2024
8 tasks
@pi0 pi0 marked this pull request as ready for review December 30, 2024 14:54
@pi0 pi0 changed the title fix(parse)!: fixed root handling fix(parse)!: fix root handling to be consistent with node Dec 30, 2024
@pi0 pi0 merged commit 4bcf68f into main Dec 30, 2024
@pi0 pi0 deleted the fix-parse branch January 3, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants