fix: .well-known static folder not working (#3676)

This folder is typically used for site metadata like `security.txt` and
other stuff.
This commit is contained in:
Marvin Hagemeister
2026-02-11 14:19:33 +01:00
committed by GitHub
parent 9f68496aa9
commit 3d8091602c
2 changed files with 41 additions and 4 deletions
+5 -4
View File
@@ -142,7 +142,7 @@ export class MemoryBuildCache<State> implements DevBuildCache<State> {
for (let i = 0; i < transformed.length; i++) {
const file = transformed[i];
const relative = path.relative(this.#config.staticDir, file.path);
if (relative.startsWith(".")) {
if (relative.startsWith("..")) {
throw new Error(
`Processed file resolved outside of static dir ${file.path}`,
);
@@ -158,7 +158,7 @@ export class MemoryBuildCache<State> implements DevBuildCache<State> {
try {
const filePath = path.join(this.#config.staticDir, pathname);
const relative = path.relative(this.#config.staticDir, filePath);
if (!relative.startsWith(".") && (await Deno.stat(filePath)).isFile) {
if (!relative.startsWith("..") && (await Deno.stat(filePath)).isFile) {
const pathname = new URL(relative, "http://localhost").pathname;
this.addUnprocessedFile(pathname, this.#config.staticDir);
return this.readFile(pathname);
@@ -301,8 +301,9 @@ export class DiskBuildCache<State> implements DevBuildCache<State> {
includeDirs: false,
includeFiles: true,
followSymlinks: false,
// Skip any folder or file starting with a "."
skip: [/\/\.[^/]+(\/|$)/],
// Skip any folder or file starting with a ".", but allow
// ".well-known" for things like PWA manifests
skip: [/\/\.(?!well-known)[^/]+(\/|$)/],
});
for await (const entry of entries) {