@adminforth/upload 2.15.1 → 2.15.3

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/build.log CHANGED
@@ -12,5 +12,5 @@ custom/preview.vue
12
12
  custom/tsconfig.json
13
13
  custom/uploader.vue
14
14
 
15
- sent 68,569 bytes received 153 bytes 137,444.00 bytes/sec
16
- total size is 68,007 speedup is 0.99
15
+ sent 68,577 bytes received 153 bytes 137,460.00 bytes/sec
16
+ total size is 68,023 speedup is 0.99
@@ -127,7 +127,7 @@ const maxWidth = computed(() => {
127
127
  ? (props.meta.maxShowWidth || props.meta.maxWidth)
128
128
  : (props.meta.maxListWidth || props.meta.maxWidth);
129
129
 
130
- return width ? { maxWidth: width } : {};
130
+ return width ? { maxWidth: `min(100%, ${width})` } : {};
131
131
  });
132
132
 
133
133
  const minWidth = computed(() => {
@@ -127,7 +127,7 @@ const maxWidth = computed(() => {
127
127
  ? (props.meta.maxShowWidth || props.meta.maxWidth)
128
128
  : (props.meta.maxListWidth || props.meta.maxWidth);
129
129
 
130
- return width ? { maxWidth: width } : {};
130
+ return width ? { maxWidth: `min(100%, ${width})` } : {};
131
131
  });
132
132
 
133
133
  const minWidth = computed(() => {
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.3",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",