mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
expliciting type checks and predicates (server only)
This commit is contained in:
parent
5f7021c33d
commit
c1e791bad0
34 changed files with 127 additions and 84 deletions
|
@ -51,7 +51,7 @@ function isFileValid (
|
|||
files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[],
|
||||
mimeTypeRegex: string,
|
||||
field: string,
|
||||
maxSize: number,
|
||||
maxSize: number | null,
|
||||
optional = false
|
||||
) {
|
||||
// Should have files
|
||||
|
@ -69,7 +69,7 @@ function isFileValid (
|
|||
if (!file || !file.originalname) return false
|
||||
|
||||
// Check size
|
||||
if (maxSize && file.size > maxSize) return false
|
||||
if ((maxSize !== null) && file.size > maxSize) return false
|
||||
|
||||
return new RegExp(`^${mimeTypeRegex}$`, 'i').test(file.mimetype)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue