summaryrefslogtreecommitdiff
path: root/workers
diff options
context:
space:
mode:
Diffstat (limited to 'workers')
-rw-r--r--workers/branch/src/index.ts7
-rw-r--r--workers/branch/test/content.test.ts3
2 files changed, 6 insertions, 4 deletions
diff --git a/workers/branch/src/index.ts b/workers/branch/src/index.ts
index 7cdaaf14..47ef3ad6 100644
--- a/workers/branch/src/index.ts
+++ b/workers/branch/src/index.ts
@@ -6,13 +6,12 @@ export interface Env {
export type CacheClass = "page" | "asset";
-// Binary/media assets get the longer asset cache class, alongside .pdf and the Sphinx
-// /_static/ (theme) + /_images/ (figure) trees.
-const ASSET_EXT_RE = /\.(png|jpe?g|svg|gif|ico|woff2?|ttf|eot)$/i;
+// Binary/media asset extensions (case-insensitive, so ".PDF" also matches) get the longer
+// asset cache class, alongside the Sphinx /_static/ (theme) + /_images/ (figure) trees.
+const ASSET_EXT_RE = /\.(pdf|png|jpe?g|webp|svg|gif|ico|woff2?|ttf|otf|eot)$/i;
export function classifyPath(path: string): CacheClass {
if (
- path.endsWith(".pdf") ||
path.includes("/_static/") ||
path.includes("/_images/") ||
ASSET_EXT_RE.test(path)
diff --git a/workers/branch/test/content.test.ts b/workers/branch/test/content.test.ts
index 94a0d5a6..6d04c35b 100644
--- a/workers/branch/test/content.test.ts
+++ b/workers/branch/test/content.test.ts
@@ -243,8 +243,11 @@ describe("asset cache-class classification (ยง3.3, extended)", () => {
"/en/rolling/_static/fonts/roboto.woff2",
"/en/rolling/logo.svg",
"/en/rolling/photo.jpeg",
+ "/en/rolling/hero.webp", // webp added to ASSET_EXT_RE (standalone path)
+ "/en/rolling/font.otf", // otf added to ASSET_EXT_RE (standalone path)
"/en/rolling/icon.ico",
"/en/rolling/vyos-documentation.pdf",
+ "/en/rolling/vyos-documentation.PDF", // .pdf folded into the case-insensitive regex
]) {
expect(classifyPath(p)).toBe("asset");
}