Skip to content

Commit af0f23c

Browse files
authored
fix: font file type check for better browser compatibility (@byseif21) (monkeytypegame#6836)
### Description * browsers don't provide accurate MIME types for font files , I couldn't even reuse the site fonts as local fonts. * Validation now checks both MIME type and file extension to ensure valid fonts aren't mistakenly rejected.
1 parent 31585bd commit af0f23c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

frontend/src/ts/elements/settings/custom-font-picker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ uploadContainerEl
5252
}
5353

5454
// check type
55-
if (!file.type.match(/font\/(woff|woff2|ttf|otf)/)) {
55+
if (
56+
!file.type.match(/font\/(woff|woff2|ttf|otf)/) &&
57+
!file.name.match(/\.(woff|woff2|ttf|otf)$/i)
58+
) {
5659
Notifications.add(
5760
"Unsupported font format, must be woff, woff2, ttf or otf.",
5861
0

0 commit comments

Comments
 (0)