fix: font file type check for better browser compatibility (@byseif21) (#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.
This commit is contained in:
Seif Soliman 2025-08-05 14:57:26 +03:00 committed by GitHub
parent 31585bd0b2
commit af0f23c940
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,7 +52,10 @@ uploadContainerEl
}
// check type
if (!file.type.match(/font\/(woff|woff2|ttf|otf)/)) {
if (
!file.type.match(/font\/(woff|woff2|ttf|otf)/) &&
!file.name.match(/\.(woff|woff2|ttf|otf)$/i)
) {
Notifications.add(
"Unsupported font format, must be woff, woff2, ttf or otf.",
0