File tree 2 files changed +30
-2
lines changed
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -1432,6 +1432,34 @@ describe('Parse.File testing', () => {
1432
1432
}
1433
1433
} ) ;
1434
1434
1435
+ it ( 'allows file without extension' , async ( ) => {
1436
+ await reconfigureServer ( {
1437
+ fileUpload : {
1438
+ enableForPublic : true ,
1439
+ fileExtensions : [ '^[^hH][^tT][^mM][^lL]?$' ] ,
1440
+ } ,
1441
+ } ) ;
1442
+ const headers = {
1443
+ 'X-Parse-Application-Id' : 'test' ,
1444
+ 'X-Parse-REST-API-Key' : 'rest' ,
1445
+ } ;
1446
+
1447
+ const values = [ 'filenamewithoutextension' ] ;
1448
+
1449
+ for ( const value of values ) {
1450
+ await expectAsync (
1451
+ request ( {
1452
+ method : 'POST' ,
1453
+ headers : headers ,
1454
+ url : `http://localhost:8378/1/files/${ value } ` ,
1455
+ body : '<html></html>\n' ,
1456
+ } ) . catch ( e => {
1457
+ throw new Error ( e . data . error ) ;
1458
+ } )
1459
+ ) . toBeResolved ( ) ;
1460
+ }
1461
+ } ) ;
1462
+
1435
1463
it ( 'works with array' , async ( ) => {
1436
1464
await reconfigureServer ( {
1437
1465
fileUpload : {
Original file line number Diff line number Diff line change @@ -159,9 +159,9 @@ export class FilesRouter {
159
159
} else if ( contentType && contentType . includes ( '/' ) ) {
160
160
extension = contentType . split ( '/' ) [ 1 ] ;
161
161
}
162
- extension = extension . split ( ' ' ) . join ( '' ) ;
162
+ extension = extension ? .split ( ' ' ) ? .join ( '' ) ;
163
163
164
- if ( ! isValidExtension ( extension ) ) {
164
+ if ( extension && ! isValidExtension ( extension ) ) {
165
165
next (
166
166
new Parse . Error (
167
167
Parse . Error . FILE_SAVE_ERROR ,
You can’t perform that action at this time.
0 commit comments