@tryghost/mg-fs-utils 0.14.1 → 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.
Files changed (2) hide show
  1. package/lib/FileCache.js +11 -2
  2. package/package.json +6 -6
package/lib/FileCache.js CHANGED
@@ -181,9 +181,18 @@ export default class FileCache {
181
181
  resolveFileName(filename, type = 'images') {
182
182
  const ext = extname(filename);
183
183
 
184
- // Replace any dots in the path with dashes
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
+
193
+ // Replace any dots and spaces in the path with dashes
185
194
  const parsedPath = parse(filename);
186
- parsedPath.dir = parsedPath.dir.replace(/\./g, '-');
195
+
187
196
  filename = format(parsedPath);
188
197
 
189
198
  let typeDir = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-fs-utils",
3
- "version": "0.14.1",
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,17 +25,17 @@
25
25
  "jest-extended": "4.0.2"
26
26
  },
27
27
  "dependencies": {
28
- "@tryghost/errors": "1.3.2",
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.43",
32
- "adm-zip": "0.5.12",
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",
36
36
  "lodash": "4.17.21",
37
- "sharp": "0.32.6",
37
+ "sharp": "0.33.4",
38
38
  "transliteration": "2.3.5"
39
39
  },
40
- "gitHead": "f824cede3d1123defe3e4575536dd579984f7fe2"
40
+ "gitHead": "c1d13ccea270adcaf60dfc9d1e371ef25dfad31e"
41
41
  }