fix(imaging): support .hab assets, cache avatars/badges, harden routes
The hotel moved from .nitro to .hab bundles, so the imager must treat .hab like .nitro and the public avatar endpoints must accept the figure strings the client sends (including extra trailing segments such as `.0`, which the old FIGURE_RE rejected with a 400). - imager-upstream: relax FIGURE_RE, extend parseAvatarQuery test coverage - api/imaging/avatar + /imaging: shared validation, placeholder and ETag/304 - api/imaging/badge: single-flight upstream fetch and conditional responses - imager-http/imager-png: strong ETag helpers and APNG passthrough guard - csp + next/image: unoptimized external images, tightened CSP - deps: override postcss-selector-parser to ^7.1.6 - also fold in the pending drizzle draft snapshot and stray test cleanup
This commit is contained in:
1 parent
56676effc3
commit
f3407ebfdf
29 files changed
+15134
-93
No files matched your search
@@ -15,7 +15,11 @@ vi.mock("@/lib/runtime-asset-config", () => ({
|
||||
resolveImagerBase: (origin: string) => `${origin}/imager`,
|
||||
}));
|
||||
|
||||
import { fetchAvatarImage, ImagerUnavailableError } from "./imager-upstream";
|
||||
import {
|
||||
fetchAvatarImage,
|
||||
ImagerUnavailableError,
|
||||
parseAvatarQuery,
|
||||
} from "./imager-upstream";
|
||||
|
||||
const params = new URLSearchParams({ figure: "hr-1", direction: "2" });
|
||||
|
||||
@@ -136,3 +140,19 @@ it("does not queue a new caller behind a render that is already too old", async
|
||||
expect([...shared[0].body]).toEqual([9]);
|
||||
expect(shared[1].body).toBe(shared[0].body);
|
||||
});
|
||||
|
||||
it("accepts figures the renderer understands even with a trailing segment", () => {
|
||||
// The client appends extra segments the imager still draws (e.g. the
|
||||
// trailing `.0` here). Rejecting them turned valid avatars into 400s.
|
||||
const figure =
|
||||
"hr-11782-40-40.hd-180-7-14.ch-11592-66.lg-10726-79-1408.sh-11764-1408.ha-11958-70-1408.wa-2007-0.0";
|
||||
const parsed = parseAvatarQuery(new URLSearchParams({ figure }));
|
||||
expect(parsed.ok).toBe(true);
|
||||
if (parsed.ok) expect(parsed.params.get("figure")).toBe(figure);
|
||||
});
|
||||
|
||||
it("still rejects a figure that is not a figure", () => {
|
||||
for (const figure of ["../bad", "hd-180-1/../x", "", "0"]) {
|
||||
expect(parseAvatarQuery(new URLSearchParams({ figure })).ok).toBe(false);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user