fix: custom mime configuration was not effective inside web-page folders
Massimo Melina committed
Oct 5, 2024 at 14:30 UTC
f09a62fb4ca04c6068c5f2df2378de262c3187c2
2 files changed
+2
-4
src/serveFile.ts
+2
-2
@@ -51,7 +51,7 @@ export async function serveFileNode(ctx: Koa.Context, node: VfsNode) {
51
}
52
}
53
54
-const mimeCfg = defineConfig<Dict<string>, (name: string) => string | undefined>('mime', { '*': MIME_AUTO }, obj => {
54
+const mimeCfg = defineConfig<Dict<string>, (name: string) => string | undefined>('mime', {}, obj => {
55
const matchers = Object.keys(obj).map(k => makeMatcher(k))
56
const values = Object.values(obj)
57
return (name: string) => values[matchers.findIndex(matcher => matcher(name))]
@@ -65,7 +65,7 @@ export async function serveFile(ctx: Koa.Context, source:string, mime?:string, c
65
return
66
const fn = basename(source)
67
mime = mime ?? mimeCfg.compiled()(fn)
68
- if (!mime || mime === MIME_AUTO)
68
+ if (mime === undefined || mime === MIME_AUTO)
69
mime = mimetypes.lookup(source) || ''
70
if (mime)
71
ctx.type = mime
src/vfs.ts
-2
@@ -109,8 +109,6 @@ export async function urlToNode(url: string, ctx?: Koa.Context, parent: VfsNode=
109
const ret = await getNodeByName(name, parent)
110
if (!ret)
111
return
112
- if (parent.default) // web folders have this default setting to ensure a standard behavior
113
- inheritFromParent({ mime: { '*': MIME_AUTO } }, ret)
112
if (rest || ret?.original)
113
return urlToNode(rest, ctx, ret, getRest)
114
if (ret.source)