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 @@ -1364,6 +1364,34 @@ describe('Parse.File testing', () => {
1364
1364
) ;
1365
1365
} ) ;
1366
1366
1367
+ it ( 'allows file without extension' , async ( ) => {
1368
+ await reconfigureServer ( {
1369
+ fileUpload : {
1370
+ enableForPublic : true ,
1371
+ fileExtensions : [ '^[^hH][^tT][^mM][^lL]?$' ] ,
1372
+ } ,
1373
+ } ) ;
1374
+ const headers = {
1375
+ 'X-Parse-Application-Id' : 'test' ,
1376
+ 'X-Parse-REST-API-Key' : 'rest' ,
1377
+ } ;
1378
+
1379
+ const values = [ 'filenamewithoutextension' ] ;
1380
+
1381
+ for ( const value of values ) {
1382
+ await expectAsync (
1383
+ request ( {
1384
+ method : 'POST' ,
1385
+ headers : headers ,
1386
+ url : `http://localhost:8378/1/files/${ value } ` ,
1387
+ body : '<html></html>\n' ,
1388
+ } ) . catch ( e => {
1389
+ throw new Error ( e . data . error ) ;
1390
+ } )
1391
+ ) . toBeResolved ( ) ;
1392
+ }
1393
+ } ) ;
1394
+
1367
1395
it ( 'works with array' , async ( ) => {
1368
1396
await reconfigureServer ( {
1369
1397
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