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({
|
||||
fileUpload: {
|
||||
enableForPublic: true,
|
||||
fileExtensions: ['jpg'],
|
||||
fileExtensions: ['jpg', 'wav'],
|
||||
},
|
||||
});
|
||||
await expectAsync(
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user