From 04d6f72561fadb7759b3c13b38311262177a9d19 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 18 Nov 2022 10:30:22 +0100 Subject: [PATCH] chore(file-attachment): support woff/woff2 --- build/index.ts | 4 +++- content/file-attachment.ts | 2 +- server/index.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build/index.ts b/build/index.ts index fab5a6aa93a8..2b674b1a7b52 100644 --- a/build/index.ts +++ b/build/index.ts @@ -272,7 +272,9 @@ function getAdjacentFileAttachments(documentDirectory) { // This needs to match what we do in filecheck/checker.py return ( !dirent.isDirectory() && - /\.(mp3|mp4|png|jpeg|jpg|gif|ogg|svg|ttf|webm|webp)$/i.test(dirent.name) + /\.(mp3|mp4|png|jpeg|jpg|gif|ogg|svg|ttf|webm|webp|woff2?)$/i.test( + dirent.name + ) ); }) .map((dirent) => path.join(documentDirectory, dirent.name)); diff --git a/content/file-attachment.ts b/content/file-attachment.ts index 59bb8a6a725f..8d728d79dd85 100644 --- a/content/file-attachment.ts +++ b/content/file-attachment.ts @@ -27,7 +27,7 @@ function isAudio(filePath: string) { } function isFont(filePath: string) { - return /\.(ttf)$/i.test(filePath); + return /\.(ttf|woff2?)$/i.test(filePath); } function isVideo(filePath: string) { diff --git a/server/index.ts b/server/index.ts index 58b75247b391..8464c0be9512 100644 --- a/server/index.ts +++ b/server/index.ts @@ -224,7 +224,9 @@ app.get("/*", async (req, res, ...args) => { // TODO: Would be nice to have a list of all supported file extensions // in a constants file. - if (/\.(gif|jpe?g|mp3|mp4|png|ogg|svg|ttf|webm|webp)$/.test(req.path)) { + if ( + /\.(gif|jpe?g|mp3|mp4|png|ogg|svg|ttf|webm|webp|woff2?)$/.test(req.path) + ) { // Remember, FileAttachment.findByURLWithFallback() will return the absolute file path // iff it exists on disk. // Using a "fallback" strategy here so that images embedded in live samples