@adminforth/upload 2.15.1 → 2.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -40,7 +40,13 @@ export default class UploadPlugin extends AdminForthPlugin {
40
40
  const pkName = (_a = this.resourceConfig.columns.find((column) => column.primaryKey)) === null || _a === void 0 ? void 0 : _a.name;
41
41
  record = yield this.adminforth.resource(this.resourceConfig.resourceId).get([Filters.EQ(pkName, recordPk)]);
42
42
  }
43
- const filePath = this.options.filePath({ originalFilename, originalExtension, contentType, record });
43
+ const sanitizeFileName = (name) => {
44
+ return name
45
+ .normalize("NFKD")
46
+ .replace(/[^a-zA-Z0-9._-]/g, "_");
47
+ };
48
+ const fileName = sanitizeFileName(originalFilename);
49
+ const filePath = this.options.filePath({ originalFilename: fileName, originalExtension, contentType, record });
44
50
  if (filePath.startsWith('/')) {
45
51
  throw new Error('s3Path should not start with /, please adjust s3path function to not return / at the start of the path');
46
52
  }
package/index.ts CHANGED
@@ -60,7 +60,13 @@ export default class UploadPlugin extends AdminForthPlugin {
60
60
  )
61
61
  }
62
62
 
63
- const filePath: string = this.options.filePath({ originalFilename, originalExtension, contentType, record });
63
+ const sanitizeFileName = (name) => {
64
+ return name
65
+ .normalize("NFKD")
66
+ .replace(/[^a-zA-Z0-9._-]/g, "_")
67
+ }
68
+ const fileName = sanitizeFileName(originalFilename);
69
+ const filePath: string = this.options.filePath({ originalFilename: fileName, originalExtension, contentType, record });
64
70
  if (filePath.startsWith('/')) {
65
71
  throw new Error('s3Path should not start with /, please adjust s3path function to not return / at the start of the path');
66
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "2.15.1",
3
+ "version": "2.15.2",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",