Skip to content

Commit b9aba99

Browse files
jameswraggpi0
andauthored
fix: correctly handle format_auto,animated (#235)
Co-authored-by: Pooya Parsa <[email protected]>
1 parent e307855 commit b9aba99

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ Change format to `webp` and keep other things same as source:
9595

9696
`/f_webp/static/buffalo.png`
9797

98+
Automatically convert to a preferred format (avif/webp/jpeg). Uses the browsers `accept` header to negotiate:
99+
100+
`/f_auto/static/buffalo.png`
101+
98102
Keep original format (`png`) and set width to `200`:
99103

100104
`/w_200/static/buffalo.png`

src/server.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ export function createIPXH3Handler(ipx: IPX) {
6464
const mFormat = modifiers.f || modifiers.format;
6565
if (mFormat === "auto") {
6666
const acceptHeader = getRequestHeader(event, "accept") || "";
67+
const animated = modifiers.animated ?? modifiers.a;
6768
const autoFormat = autoDetectFormat(
6869
acceptHeader,
69-
!!(modifiers.a || modifiers.animated),
70+
// #234 "animated" param adds {animated: ''} to the modifiers
71+
// TODO: fix modifiers to normalized to boolean
72+
!!animated || animated === "",
7073
);
7174
delete modifiers.f;
7275
delete modifiers.format;

0 commit comments

Comments
 (0)