File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
kleros-app/src/lib/atlas/providers Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,16 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea
281281 const restrictions = roleRestrictions . find ( ( supportedRoles ) => Roles [ supportedRoles . name ] === role ) ;
282282
283283 if ( ! restrictions ) throw new Error ( "Unsupported role." ) ;
284- if ( ! restrictions . restriction . allowedMimeTypes . includes ( file . type ) ) throw new Error ( "Unsupported file type." ) ;
284+
285+ const isValidMimeType = restrictions . restriction . allowedMimeTypes . some ( ( allowedType ) => {
286+ if ( allowedType . endsWith ( "/*" ) ) {
287+ const prefix = allowedType . replace ( "/*" , "/" ) ;
288+ return file . type . startsWith ( prefix ) ;
289+ }
290+ return allowedType === file . type ;
291+ } ) ;
292+
293+ if ( ! isValidMimeType ) throw new Error ( "Unsupported file type." ) ;
285294 if ( file . size > restrictions . restriction . maxSize )
286295 throw new Error (
287296 `File too big. Max allowed size : ${ ( restrictions . restriction . maxSize / ( 1024 * 1024 ) ) . toFixed ( 2 ) } mb.`
You can’t perform that action at this time.
0 commit comments