Skip to content

Commit 7682675

Browse files
fix assets in directories starting with . (#8655)
* add allow dot files * test * changeset * include wrangler in patch --------- Co-authored-by: Carmen Popoviciu <[email protected]>
1 parent fc66a2b commit 7682675

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

.changeset/cute-plants-wash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"miniflare": patch
3+
"wrangler": patch
4+
---
5+
6+
fix bug where assets in directories starting with . would crash the dev server
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi from .dot/index.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi from .dotfile.html

fixtures/workers-with-assets/tests/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,22 @@ describe("[Workers + Assets] dynamic site", () => {
247247
// let response = await fetch(`http://${ip}:${port}/_worker.js`);
248248
// expect(await response.text()).not.toContain("bang");
249249
});
250+
251+
it("should work with files which start with .", async ({ expect }) => {
252+
let response = await fetch(`http://${ip}:${port}/.dot`);
253+
let text = await response.text();
254+
expect(response.status).toBe(200);
255+
expect(text).toMatchInlineSnapshot(`
256+
"hi from .dot/index.html
257+
"
258+
`);
259+
260+
response = await fetch(`http://${ip}:${port}/.dotfile.html`);
261+
text = await response.text();
262+
expect(response.status).toBe(200);
263+
expect(text).toMatchInlineSnapshot(`
264+
"hi from .dotfile.html
265+
"
266+
`);
267+
});
250268
});

packages/miniflare/src/plugins/assets/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ export const ASSETS_PLUGIN: Plugin<typeof AssetsOptionsSchema> = {
8585
const storageServiceName = `${ASSETS_PLUGIN_NAME}:storage`;
8686
const storageService: Service = {
8787
name: storageServiceName,
88-
disk: { path: options.assets.directory, writable: true },
88+
disk: {
89+
path: options.assets.directory,
90+
writable: true,
91+
allowDotfiles: true,
92+
},
8993
};
9094

9195
const { encodedAssetManifest, assetsReverseMap } = await buildAssetManifest(

packages/miniflare/src/runtime/config/workerd.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export interface Network {
204204
export interface DiskDirectory {
205205
path?: string;
206206
writable?: boolean;
207+
allowDotfiles?: boolean;
207208
}
208209

209210
export interface HttpOptions {

0 commit comments

Comments
 (0)