Skip to content

Commit 6a4a00c

Browse files
fix: Parse Server option fileUpload.fileExtensions does not work with an array of extensions (#8688)
1 parent c9b5971 commit 6a4a00c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

Diff for: spec/ParseFile.spec.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ describe('Parse.File testing', () => {
13681368
await reconfigureServer({
13691369
fileUpload: {
13701370
enableForPublic: true,
1371-
fileExtensions: ['jpg'],
1371+
fileExtensions: ['jpg', 'wav'],
13721372
},
13731373
});
13741374
await expectAsync(
@@ -1387,6 +1387,30 @@ describe('Parse.File testing', () => {
13871387
).toBeRejectedWith(
13881388
new Parse.Error(Parse.Error.FILE_SAVE_ERROR, `File upload of extension html is disabled.`)
13891389
);
1390+
await expectAsync(
1391+
request({
1392+
method: 'POST',
1393+
url: 'http://localhost:8378/1/files/file',
1394+
body: JSON.stringify({
1395+
_ApplicationId: 'test',
1396+
_JavaScriptKey: 'test',
1397+
_ContentType: 'image/jpg',
1398+
base64: 'PGh0bWw+PC9odG1sPgo=',
1399+
}),
1400+
})
1401+
).toBeResolved();
1402+
await expectAsync(
1403+
request({
1404+
method: 'POST',
1405+
url: 'http://localhost:8378/1/files/file',
1406+
body: JSON.stringify({
1407+
_ApplicationId: 'test',
1408+
_JavaScriptKey: 'test',
1409+
_ContentType: 'audio/wav',
1410+
base64: 'UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA',
1411+
}),
1412+
})
1413+
).toBeResolved();
13901414
});
13911415

13921416
it('works with array without Content-Type', async () => {

Diff for: src/Routers/FilesRouter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class FilesRouter {
147147
if (ext === '*') {
148148
return true;
149149
}
150-
const regex = new RegExp(fileExtensions);
150+
const regex = new RegExp(ext);
151151
if (regex.test(extension)) {
152152
return true;
153153
}

0 commit comments

Comments
 (0)