fix: omit raw format from direct image URLs

This commit is contained in:
Oleg Isonen committed 2026-08-05 10:17:15 +01:00
1 parent c44ef705cf
commit 86357c8474
5 files changed
+10 -18

No files matched your search

@@ -36,12 +36,8 @@ test("resolves asset IDs and relative paths in Markdown images and links", () =>
origin: "https://builder.example",
});
expect(html).toContain(
'src="https://builder.example/cgi/image/image.png?format=raw"'
);
expect(html).toContain(
'href="https://builder.example/cgi/image/image.png?format=raw"'
);
expect(html).toContain('src="https://builder.example/cgi/image/image.png"');
expect(html).toContain('href="https://builder.example/cgi/image/image.png"');
expect(html).toContain('src="https://example.com/image.png"');
});
+1 -3
View File
@@ -136,9 +136,7 @@ test("downloads asset files when they are missing from the synced asset cache",
await expect(readFile("public/assets/image.png", "utf8")).resolves.toBe(
"downloaded"
);
expect(fetch).toHaveBeenCalledWith(
"https://example.com/cgi/image/image.png?format=raw"
);
expect(fetch).toHaveBeenCalledWith("https://example.com/cgi/image/image.png");
});
test("retries asset download once after a server error", async () => {
+1 -1
View File
@@ -2558,7 +2558,7 @@ describe("prebuild", () => {
template: ["defaults"],
});
expect(fetch).toHaveBeenCalledWith(
"https://assets.example/cgi/image/image.png?format=raw"
"https://assets.example/cgi/image/image.png"
);
expect(consoleWarn).not.toHaveBeenCalled();
expect(consoleError).toHaveBeenCalledWith(
+5 -7
View File
@@ -593,11 +593,9 @@ describe("allowed-file-types", () => {
test("generates correct URL for image assets", () => {
const url = getAssetUrl(mockImageAsset, "https://example.com");
expect(url.href).toBe(
"https://example.com/cgi/image/photo.jpg?format=raw"
);
expect(url.href).toBe("https://example.com/cgi/image/photo.jpg");
expect(url.pathname).toBe("/cgi/image/photo.jpg");
expect(url.search).toBe("?format=raw");
expect(url.search).toBe("");
});
test.each(["bmp", "ico", "avif"])(
@@ -1048,7 +1046,7 @@ describe("allowed-file-types", () => {
test("converts image asset with all fields", () => {
const result = toRuntimeAsset(mockImageAsset, "https://example.com");
expect(result).toEqual({
url: "/cgi/image/photo.jpg?format=raw",
url: "/cgi/image/photo.jpg",
width: 1920,
height: 1080,
});
@@ -1086,8 +1084,8 @@ describe("allowed-file-types", () => {
const result1 = toRuntimeAsset(mockImageAsset, "https://cdn.example.com");
const result2 = toRuntimeAsset(mockImageAsset, "http://localhost:3000");
// Both should return the same relative URL
expect(result1.url).toBe("/cgi/image/photo.jpg?format=raw");
expect(result2.url).toBe("/cgi/image/photo.jpg?format=raw");
expect(result1.url).toBe("/cgi/image/photo.jpg");
expect(result2.url).toBe("/cgi/image/photo.jpg");
});
test("handles image without dimensions", () => {
+1 -1
View File
@@ -543,7 +543,7 @@ export const getAssetUrl = (
origin: string
): URL => {
const path = isResizableImageFileName(asset.name)
? `/cgi/image/${asset.name}?format=raw`
? `/cgi/image/${asset.name}`
: `/cgi/asset/${asset.name}?format=raw`;
return new URL(path, origin);
};