Skip to content

fix(create): accept target directory names that contain two dots - #3545

Merged
fengmk2 merged 2 commits into
voidzero-dev:mainfrom
thejesh23:fix/create-dotted-dir-name
Nov 23, 2026
Merged

fengmk2 merged 2 commits into
voidzero-dev:mainfrom
thejesh23:fix/create-dotted-dir-name

Conversation

@thejesh23

Copy link
Copy Markdown
Contributor

vp create rejects target directories whose name contains two consecutive dots, even though they don't leave the current directory:

$ vp create vite:library --directory my..lib --no-interactive
■ Relative path contains ".." which is not allowed
The --directory option is invalid
exit=1

my..lib is a valid package name (validate-npm-package-name returns validForNewPackages: true), and a directory called my..lib stays inside the current directory. formatTargetDir in packages/cli/src/create/utils.ts and validateTargetDir in packages/cli/src/create/prompts.ts (the interactive "Target directory" prompt) test targetDir.includes('..'), which is a substring check. This PR checks for a .. path segment instead: targetDir.split(/[\\/]/).includes('..'). Both functions call it on the path.normalized input, as before.

Behavior before and after, for formatTargetDir:

input before after
.., ../, ../x, a/../.., foo/../../x, x/@s/.. rejected (..) rejected (..), unchanged
my..lib, ./my..lib, foo.., a/b..c/d, @s/my..lib rejected (..) accepted
..., ..foo rejected (..) rejected by package-name validation ("name cannot start with a period")
.../x rejected (..) accepted (... is an ordinary directory name)

All other inputs I tried (., ./, absolute paths, scoped paths, @scope/) give the same result as before.

Tests: utils.spec.ts and prompts.spec.ts get one case each. They cover .. segments, which are still rejected, and my..lib-style names, which are now accepted. Both cases fail on main and pass with this change.

Validation (macOS arm64, Node 24.22.3). I couldn't build the monorepo locally (no Rust toolchain, rolldown/vite not synced), so I ran the checks with the published vite-plus@1.7.0 toolchain against this checkout:

  • vp test run packages/cli/src: no new failures. The failing files are the same as on unmodified main in this setup, because of missing workspace builds (for example @voidzero-dev/vite-task-client) and vi.spyOn on the npm build of @voidzero-dev/vite-plus-prompts. Those failures are unrelated to this change.
  • vp fmt --check and vp lint --type-aware --type-check on the changed files: clean.

🤖 Generated with Claude Code

The ".." guard in formatTargetDir and the interactive target-directory
validator used a substring check, so names such as my..lib were rejected
with 'Relative path contains ".."' even though they do not leave the
current directory. Check for a ".." path segment instead.
@fengmk2 fengmk2 self-assigned this Nov 23, 2026

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thejesh23 Thanks!

@fengmk2

fengmk2 commented Nov 23, 2026

Copy link
Copy Markdown
Member

I will handle the lint errors, they are unrelated to the current PR.

@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: create-e2e Run `vp create` e2e tests labels Nov 23, 2026
@fengmk2
fengmk2 merged commit abdad51 into voidzero-dev:main Nov 23, 2026
186 of 211 checks passed
@fengmk2 fengmk2 mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants