Repository navigation
fix(create): accept target directory names that contain two dots - #3545
Merged
Merged
Conversation
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.
Member
|
I will handle the lint errors, they are unrelated to the current PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vp createrejects target directories whose name contains two consecutive dots, even though they don't leave the current directory:my..libis a valid package name (validate-npm-package-namereturnsvalidForNewPackages: true), and a directory calledmy..libstays inside the current directory.formatTargetDirinpackages/cli/src/create/utils.tsandvalidateTargetDirinpackages/cli/src/create/prompts.ts(the interactive "Target directory" prompt) testtargetDir.includes('..'), which is a substring check. This PR checks for a..path segment instead:targetDir.split(/[\\/]/).includes('..'). Both functions call it on thepath.normalized input, as before.Behavior before and after, for
formatTargetDir:..,../,../x,a/../..,foo/../../x,x/@s/....)..), unchangedmy..lib,./my..lib,foo..,a/b..c/d,@s/my..lib..)...,..foo..).../x..)...is an ordinary directory name)All other inputs I tried (
.,./, absolute paths, scoped paths,@scope/) give the same result as before.Tests:
utils.spec.tsandprompts.spec.tsget one case each. They cover..segments, which are still rejected, andmy..lib-style names, which are now accepted. Both cases fail onmainand pass with this change.Validation (macOS arm64, Node 24.22.3). I couldn't build the monorepo locally (no Rust toolchain,
rolldown/vitenot synced), so I ran the checks with the publishedvite-plus@1.7.0toolchain against this checkout:vp test run packages/cli/src: no new failures. The failing files are the same as on unmodifiedmainin this setup, because of missing workspace builds (for example@voidzero-dev/vite-task-client) andvi.spyOnon the npm build of@voidzero-dev/vite-plus-prompts. Those failures are unrelated to this change.vp fmt --checkandvp lint --type-aware --type-checkon the changed files: clean.🤖 Generated with Claude Code