diff --git a/src/core/AssetUrls.ts b/src/core/AssetUrls.ts index f1141b322..d17063a38 100644 --- a/src/core/AssetUrls.ts +++ b/src/core/AssetUrls.ts @@ -63,14 +63,6 @@ export function buildAssetUrl( return directUrl; } - const directoryPrefix = `${normalizedPath}/`; - const hasNestedAssets = Object.keys(assetManifest).some((manifestPath) => - manifestPath.startsWith(directoryPrefix), - ); - if (hasNestedAssets) { - return `/_assets/${encodeAssetPath(normalizedPath)}`; - } - return `/${encodeAssetPath(normalizedPath)}`; } diff --git a/tests/AssetUrls.test.ts b/tests/AssetUrls.test.ts index a48876e1b..935cde2d5 100644 --- a/tests/AssetUrls.test.ts +++ b/tests/AssetUrls.test.ts @@ -10,7 +10,11 @@ describe("AssetUrls", () => { ).toBe("/_assets/images/Favicon.hash.svg"); }); - test("maps directory prefixes into the hashed asset namespace", () => { + test("falls back to the unversioned path when manifest has no match", () => { + expect(buildAssetUrl("images/unknown.svg", {})).toBe("/images/unknown.svg"); + }); + + test("falls back to the unversioned path for directory-like paths", () => { const manifest = { "maps/britanniaclassic/manifest.json": "/_assets/maps/britanniaclassic/manifest.hash.json", @@ -18,16 +22,12 @@ describe("AssetUrls", () => { "/_assets/maps/britanniaclassic/map.hash.bin", }; - expect(buildAssetUrl("maps", manifest)).toBe("/_assets/maps"); + expect(buildAssetUrl("maps", manifest)).toBe("/maps"); expect(buildAssetUrl("maps/britanniaclassic", manifest)).toBe( - "/_assets/maps/britanniaclassic", + "/maps/britanniaclassic", ); }); - test("falls back to the unversioned path when manifest has no match", () => { - expect(buildAssetUrl("images/unknown.svg", {})).toBe("/images/unknown.svg"); - }); - test("rejects dot segments in asset paths", () => { expect(() => buildAssetUrl("../api/instance", {})).toThrow( "Invalid asset path segment: ..",