Skip to content

Commit

Permalink
chore(file-attachment): support woff/woff2
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Nov 25, 2022
1 parent 0195a40 commit 03a4ac7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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));
Expand Down
2 changes: 1 addition & 1 deletion content/file-attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03a4ac7

Please sign in to comment.