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 @@ -1366,6 +1366,34 @@ describe('Parse.File testing', () => {
1366
1366
) ;
1367
1367
} ) ;
1368
1368
1369
+ it ( 'allows file without extension' , async ( ) => {
1370
+ await reconfigureServer ( {
1371
+ fileUpload : {
1372
+ enableForPublic : true ,
1373
+ fileExtensions : [ '^[^hH][^tT][^mM][^lL]?$' ] ,
1374
+ } ,
1375
+ } ) ;
1376
+ const headers = {
1377
+ 'X-Parse-Application-Id' : 'test' ,
1378
+ 'X-Parse-REST-API-Key' : 'rest' ,
1379
+ } ;
1380
+
1381
+ const values = [ 'filenamewithoutextension' ] ;
1382
+
1383
+ for ( const value of values ) {
1384
+ await expectAsync (
1385
+ request ( {
1386
+ method : 'POST' ,
1387
+ headers : headers ,
1388
+ url : `http://localhost:8378/1/files/${ value } ` ,
1389
+ body : '<html></html>\n' ,
1390
+ } ) . catch ( e => {
1391
+ throw new Error ( e . data . error ) ;
1392
+ } )
1393
+ ) . toBeResolved ( ) ;
1394
+ }
1395
+ } ) ;
1396
+
1369
1397
it ( 'works with array' , async ( ) => {
1370
1398
await reconfigureServer ( {
1371
1399
fileUpload : {
Original file line number Diff line number Diff line change @@ -157,9 +157,9 @@ export class FilesRouter {
157
157
} else if ( contentType && contentType . includes ( '/' ) ) {
158
158
extension = contentType . split ( '/' ) [ 1 ] ;
159
159
}
160
- extension = extension . split ( ' ' ) . join ( '' ) ;
160
+ extension = extension ? .split ( ' ' ) ? .join ( '' ) ;
161
161
162
- if ( ! isValidExtension ( extension ) ) {
162
+ if ( extension && ! isValidExtension ( extension ) ) {
163
163
next (
164
164
new Parse . Error (
165
165
Parse . Error . FILE_SAVE_ERROR ,
You can’t perform that action at this time.
0 commit comments