drapcode-utility 1.8.8 → 1.9.0

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.
@@ -119,11 +119,7 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
119
119
  if (!(_c in _a)) return [3 /*break*/, 5];
120
120
  index = _c;
121
121
  file = files[index];
122
- fileSlug = file.originalname
123
- .replace(/\.[^/.]+$/, "")
124
- .replace(/\s+/g, "_")
125
- .replace(/[^a-zA-Z0-9_]/g, "")
126
- .toLowerCase();
122
+ fileSlug = slugifyFileName(file.originalname);
127
123
  if (s3Config.append) {
128
124
  s3Config.key = "".concat(s3Key, "/").concat((0, uuid_1.v4)(), "/").concat(fileSlug);
129
125
  }
@@ -140,11 +136,7 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
140
136
  case 6: return [2 /*return*/, fileOptions];
141
137
  case 7:
142
138
  console.log("I have single file");
143
- fileSlug = files.originalname
144
- .replace(/\.[^/.]+$/, "")
145
- .replace(/\s+/g, "_")
146
- .replace(/[^a-zA-Z0-9_]/g, "")
147
- .toLowerCase();
139
+ fileSlug = slugifyFileName(files.originalname);
148
140
  if (s3Config.append) {
149
141
  s3Config.key = "".concat(s3Config.key, "/").concat((0, uuid_1.v4)(), "/").concat(fileSlug);
150
142
  }
@@ -516,3 +508,9 @@ var generateStaticIcons = function (type) {
516
508
  }
517
509
  return { smallIcon: smallIcon, mediumIcon: mediumIcon, largeIcon: largeIcon };
518
510
  };
511
+ var slugifyFileName = function (fileName) {
512
+ return fileName
513
+ .replace(/\s+/g, "_") // Replace spaces with underscores
514
+ .replace(/[^a-zA-Z0-9._]/g, "") // Remove anything that's not a letter, number, dot, or underscore
515
+ .toLowerCase(); // Convert to lowercase
516
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.8.8",
3
+ "version": "1.9.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "dompurify": "^3.1.7",
40
40
  "drapcode-constant": "^1.6.6",
41
41
  "drapcode-logger": "^1.3.2",
42
- "drapcode-redis": "^1.2.1",
42
+ "drapcode-redis": "^1.2.2",
43
43
  "exiftool-vendored": "^28.2.1",
44
44
  "express": "^4.17.1",
45
45
  "gm": "^1.25.0",