@tryghost/mg-fs-utils 0.14.2 → 0.15.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/lib/FileCache.js +10 -3
- package/package.json +5 -5
package/lib/FileCache.js
CHANGED
|
@@ -181,11 +181,18 @@ export default class FileCache {
|
|
|
181
181
|
resolveFileName(filename, type = 'images') {
|
|
182
182
|
const ext = extname(filename);
|
|
183
183
|
|
|
184
|
+
// Replace parts of the string, but exclude the extension, and them combine them back together when done
|
|
185
|
+
let filenameNoExt = filename.replace(new RegExp(ext, 'g'), '');
|
|
186
|
+
filenameNoExt = filenameNoExt.replace(/\./g, '-'); // dots
|
|
187
|
+
filenameNoExt = filenameNoExt.replace(/ /g, '-'); // spaces
|
|
188
|
+
filenameNoExt = filenameNoExt.replace(/%20/g, '-'); // encoded spaces
|
|
189
|
+
filenameNoExt = filenameNoExt.replace(/,/g, '-'); // commas
|
|
190
|
+
filenameNoExt = filenameNoExt.replace(/%2C/g, '-'); // encoded commas
|
|
191
|
+
filename = `${filenameNoExt}${ext}`;
|
|
192
|
+
|
|
184
193
|
// Replace any dots and spaces in the path with dashes
|
|
185
194
|
const parsedPath = parse(filename);
|
|
186
|
-
|
|
187
|
-
parsedPath.dir = parsedPath.dir.replace(/ /g, '-');
|
|
188
|
-
parsedPath.dir = parsedPath.dir.replace(/%20/g, '-');
|
|
195
|
+
|
|
189
196
|
filename = format(parsedPath);
|
|
190
197
|
|
|
191
198
|
let typeDir = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-fs-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-fs-utils",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"jest-extended": "4.0.2"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tryghost/errors": "1.3.
|
|
28
|
+
"@tryghost/errors": "1.3.5",
|
|
29
29
|
"@tryghost/image-transform": "1.3.0",
|
|
30
30
|
"@tryghost/string": "0.2.12",
|
|
31
|
-
"@tryghost/zip": "1.1.
|
|
32
|
-
"adm-zip": "0.5.
|
|
31
|
+
"@tryghost/zip": "1.1.47",
|
|
32
|
+
"adm-zip": "0.5.15",
|
|
33
33
|
"csv-parse": "5.5.6",
|
|
34
34
|
"dotenv": "16.4.5",
|
|
35
35
|
"fs-extra": "11.2.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"sharp": "0.33.4",
|
|
38
38
|
"transliteration": "2.3.5"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c1d13ccea270adcaf60dfc9d1e371ef25dfad31e"
|
|
41
41
|
}
|