fix: Parse Server option fileUpload.fileExtensions does not work with an array of extensions (#8688)
This commit is contained in:
committed by
GitHub
parent
c9b59719ec
commit
6a4a00ca7a
@@ -1368,7 +1368,7 @@ describe('Parse.File testing', () => {
|
|||||||
await reconfigureServer({
|
await reconfigureServer({
|
||||||
fileUpload: {
|
fileUpload: {
|
||||||
enableForPublic: true,
|
enableForPublic: true,
|
||||||
fileExtensions: ['jpg'],
|
fileExtensions: ['jpg', 'wav'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await expectAsync(
|
await expectAsync(
|
||||||
@@ -1387,6 +1387,30 @@ describe('Parse.File testing', () => {
|
|||||||
).toBeRejectedWith(
|
).toBeRejectedWith(
|
||||||
new Parse.Error(Parse.Error.FILE_SAVE_ERROR, `File upload of extension html is disabled.`)
|
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 () => {
|
it('works with array without Content-Type', async () => {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ export class FilesRouter {
|
|||||||
if (ext === '*') {
|
if (ext === '*') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const regex = new RegExp(fileExtensions);
|
const regex = new RegExp(ext);
|
||||||
if (regex.test(extension)) {
|
if (regex.test(extension)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user