Skip to content

Commit

Permalink
fix: Parse Server option fileUpload.fileExtensions does not work wi…
Browse files Browse the repository at this point in the history
…th an array of extensions (parse-community#8688)
  • Loading branch information
BartoszMarganiec authored Jul 17, 2023
1 parent c9b5971 commit 6a4a00c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion spec/ParseFile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ describe('Parse.File testing', () => {
await reconfigureServer({
fileUpload: {
enableForPublic: true,
fileExtensions: ['jpg'],
fileExtensions: ['jpg', 'wav'],
},
});
await expectAsync(
Expand All @@ -1387,6 +1387,30 @@ describe('Parse.File testing', () => {
).toBeRejectedWith(
new Parse.Error(Parse.Error.FILE_SAVE_ERROR, `File upload of extension html is disabled.`)
);
await expectAsync(
request({
method: 'POST',
url: 'http://localhost:8378/1/files/file',
body: JSON.stringify({
_ApplicationId: 'test',
_JavaScriptKey: 'test',
_ContentType: 'image/jpg',
base64: 'PGh0bWw+PC9odG1sPgo=',
}),
})
).toBeResolved();
await expectAsync(
request({
method: 'POST',
url: 'http://localhost:8378/1/files/file',
body: JSON.stringify({
_ApplicationId: 'test',
_JavaScriptKey: 'test',
_ContentType: 'audio/wav',
base64: 'UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA',
}),
})
).toBeResolved();
});

it('works with array without Content-Type', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Routers/FilesRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class FilesRouter {
if (ext === '*') {
return true;
}
const regex = new RegExp(fileExtensions);
const regex = new RegExp(ext);
if (regex.test(extension)) {
return true;
}
Expand Down

0 comments on commit 6a4a00c

Please sign in to comment.