From 72db8482e837c9fc50b5c928ff5636ba2cbb51cf Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 12 Jun 2024 14:50:33 +0100 Subject: [PATCH] fix(public-assets): do not shadow paths that share prefix (#2516) --- src/rollup/plugins/public-assets.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rollup/plugins/public-assets.ts b/src/rollup/plugins/public-assets.ts index 7504c0edab..dc0b9d945e 100644 --- a/src/rollup/plugins/public-assets.ts +++ b/src/rollup/plugins/public-assets.ts @@ -1,5 +1,6 @@ import { promises as fsp } from "node:fs"; import { relative, resolve } from "pathe"; +import { withTrailingSlash } from "ufo"; import createEtag from "etag"; import mime from "mime"; import { globby } from "globby"; @@ -112,7 +113,10 @@ export function readAsset (id) { const publicAssetBases = Object.fromEntries( nitro.options.publicAssets .filter((dir) => !dir.fallthrough && dir.baseURL !== "/") - .map((dir) => [dir.baseURL, { maxAge: dir.maxAge }]) + .map((dir) => [ + withTrailingSlash(dir.baseURL), + { maxAge: dir.maxAge }, + ]) ); // prettier-ignore