Commit c83368a
committed
fix(path): normalize traversal segments in resolvePathFromCwd
The unification commit (1535672) replaced init.ts's resolveDestinationPath
wrapper, which did `path.resolve(expandHomePrefix(input))`. The shared
helper kept absolute inputs verbatim, dropping the implicit normalization
step that path.resolve() with one argument provides.
That regressed init.ts's filesystem-root guard
(`resolvedDest === path.parse(resolvedDest).root`), which only matches
exact-root strings. Inputs like `--dest /foo/..` or `--dest /..` resolved
to themselves, bypassing the guard, even though the kernel-level path
collapses to `/`.
Restore normalization at the helper layer by delegating unconditionally
to `path.resolve(cwd, expanded)`. `path.resolve(cwd, X)` already produces
the correct result for both absolute and relative `X`, and always
normalizes, so the absolute/relative branch is redundant. The four other
migrated call sites (build-utils, app-path-resolver, derived-data-path,
project-config) gain a benign normalization improvement; only init.ts's
guards depended on it for correctness.
Tests added cover `/foo/..` -> `/` and `/a/b/../c` -> `/a/c`.1 parent 1535672 commit c83368a
2 files changed
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
70 | 78 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
30 | 27 | | |
0 commit comments