File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 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', () => {
14321432 }
14331433 } ) ;
14341434
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+
14351463 it ( 'works with array' , async ( ) => {
14361464 await reconfigureServer ( {
14371465 fileUpload : {
Original file line number Diff line number Diff line change @@ -159,9 +159,9 @@ export class FilesRouter {
159159 } else if ( contentType && contentType . includes ( '/' ) ) {
160160 extension = contentType . split ( '/' ) [ 1 ] ;
161161 }
162- extension = extension . split ( ' ' ) . join ( '' ) ;
162+ extension = extension ? .split ( ' ' ) ? .join ( '' ) ;
163163
164- if ( ! isValidExtension ( extension ) ) {
164+ if ( extension && ! isValidExtension ( extension ) ) {
165165 next (
166166 new Parse . Error (
167167 Parse . Error . FILE_SAVE_ERROR ,
You can’t perform that action at this time.
0 commit comments