Allow files in public dir - #445
Open
freekh wants to merge 17 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: fd9ecb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR broadens Val’s “managed files” location from the hard-coded /public/val subtree to any configurable /public (or /public/...) directory, updating UI, CLI, server validation/fix flows, and core remote-ref typing/parsing to match.
Changes:
- Expand
files.directoryconfiguration support from/public/valto/publicor/public/...(CLI + shared config parsing). - Update remote ref creation/parsing/validation to allow
public/...paths instead of onlypublic/val/.... - Adjust UI utilities and components to derive display names/paths correctly with the new directory rules.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ui/spa/utils/getFilenameFromRef.ts | Updates folder derivation to strip /public rather than /public/val. |
| packages/ui/spa/search/search.worker.ts | Updates file/image search indexing label extraction for new directory scheme. |
| packages/ui/spa/components/fields/ModuleGallery.tsx | Updates remote filePath typing to accept public/... paths. |
| packages/ui/spa/components/fields/FileField.tsx | Updates remote filePath typing to accept public/... paths. |
| packages/shared/src/internal/SharedValConfig.ts | Expands config schema validation for files.directory. |
| packages/shared/src/internal/richtext/conversion/remirrorToRichTextSource.ts | Updates remote filePath typing for richtext image uploads. |
| packages/server/src/createFixPatch.ts | Broadens server-side remote download validation from public/val/ to public/. |
| packages/server/src/checkRemoteRef.ts | Broadens remote-ref filePath validation and fix-path typing to public/.... |
| packages/core/src/source/remote.ts | Updates RemoteRef template + createRemoteRef typing to accept public/.... |
| packages/core/src/schema/images.ts | Makes images() options/accept optional; defaults accept to image/*. |
| packages/core/src/remote/splitRemoteRef.ts | Broadens splitRemoteRef parsing typing/validation to public/.... |
| packages/core/src/initVal.ts | Expands ConfigDirectory type to /public or /public/.... |
| packages/cli/src/utils/evalValConfigFile.ts | Updates CLI config validation to accept /public or /public/.... |
| packages/cli/src/runValidation.ts | Broadens CLI remote upload directory enforcement to public/.... |
| packages/cli/src/listUnusedFiles.ts | Uses evaluated val.config.* to determine the managed directory instead of assuming public/val. |
| packages/cli/src/cli.ts | Updates CLI help text for list-unused-files to reflect configurable directory. |
Comments suppressed due to low confidence (1)
packages/core/src/remote/splitRemoteRef.ts:37
splitRemoteRefonly checks thatfilePathstarts withpublic/, but it does not reject path traversal segments likepublic/../.... Downstream code (e.g. server-side download topath.join(projectRoot, filePath)) can be tricked into writing outside the intended directory. Reject./..segments in the parsedfilePath.
if (match[7].indexOf("public/") !== 0) {
return {
status: "error",
error: "Invalid remote ref: " + ref,
};
}
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The RemoteRef template literal was missing the `/b/{bucket}` segment that
createRemoteRef writes and splitRemoteRef parses, so the "project id"
segment could silently absorb `/b/...`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…teRef Covers the broadened `public/...` file paths and the `.`/`..` segment rejection, including that dots inside a file name are not traversal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Aligns files.directory validation with the remote-ref checks so the directory cannot escape /public via `.` or `..` segments. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
accept is now optional and defaults to "image/*" - document that on the option and on s.images() itself, and add tests for the accept, directory, alt and remote defaults when options are omitted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
/^\/public/ also matched refs like "/publicity/a.png", mangling the displayed folder. Anchor on a segment boundary and add tests for getFilenameFromRef/getRefParts, which had none. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Since the config.files.directory fallback was removed, imageDirectory was just an alias for imageModuleDirectory. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The PR changes packages/ui/spa, but @valbuild/ui only has @valbuild/core and @valbuild/shared as devDependencies, so changesets would not bump it via the dependency graph and the studio changes would ship unversioned. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
No description provided.