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

Resolve behavior

pi0 opened this issue · comments

If an absolute windows path is passed in path.resolve behavior, it will be simply joined

What are the constraints you'd set - not use path.win32 at all, for example? It would be worth comparing the performance issues of path.win32 with whatever workaround we end up with - for example:

return path.posix.join.apply(path.posix.join, args.map(arg => normalizeWindowsPath(arg)))
// vs
return normalizeWindowsPath(path.win32.join(...args))

The end goal of this package is removing os-specific implementation and enforce POSIX. Thus path.win32 is not a preferred solution but we should use internal implementation to handle necessary edge cases. (ie your first example)

So, to clarify - do you mean by removing os-specific implementation that the purpose is (as I understood it) to enforce a consistent and reliable outcome, no matter which OS it is running on - or to avoid using platform-dependent path/path.win32 in favour of using path.posix?

Exactly :) upath solves backslash and normalization issues but still by depending on path, it has different behavior based on used os. Ideally we can at one point even bundle NodeJS path.posix implementation to make library usable also cross runtime.

Fixed in 0.2.0