drapcode-utility 1.8.9 → 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.
- package/build/utils/s3-util.js +8 -10
- package/package.json +1 -1
package/build/utils/s3-util.js
CHANGED
|
@@ -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
|
+
};
|