compressing 1.10.1 → 1.10.2

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/utils.js +13 -3
  2. package/package.json +1 -1
package/lib/utils.js CHANGED
@@ -168,6 +168,13 @@ function safePipe(streams) {
168
168
 
169
169
  exports.safePipe = safePipe;
170
170
 
171
+ function normalizePath(fileName) {
172
+ fileName = path.normalize(fileName);
173
+ // https://nodejs.org/api/path.html#path_path_normalize_path
174
+ if (process.platform === 'win32') fileName = fileName.replace(/\\+/g, '/');
175
+ return fileName;
176
+ }
177
+
171
178
  exports.stripFileName = (strip, fileName, type) => {
172
179
  // before
173
180
  // node/package.json
@@ -189,15 +196,18 @@ exports.stripFileName = (strip, fileName, type) => {
189
196
  // /foo => foo
190
197
  if (fileName[0] === '/') fileName = fileName.replace(/^\/+/, '');
191
198
 
199
+ // fix case
200
+ // ./foo/bar => foo/bar
201
+ if (fileName) {
202
+ fileName = normalizePath(fileName);
203
+ }
204
+
192
205
  let s = fileName.split('/');
193
206
 
194
207
  // fix relative path
195
208
  // foo/../bar/../../asdf/
196
209
  // => asdf/
197
210
  if (s.indexOf('..') !== -1) {
198
- fileName = path.normalize(fileName);
199
- // https://npm.taobao.org/mirrors/node/latest/docs/api/path.html#path_path_normalize_path
200
- if (process.platform === 'win32') fileName = fileName.replace(/\\+/g, '/');
201
211
  // replace '../' on ../../foo/bar
202
212
  fileName = fileName.replace(/(\.\.\/)+/, '');
203
213
  if (type === 'directory' && fileName && fileName[fileName.length - 1] !== '/') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compressing",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "Everything you need for compressing and uncompressing",
5
5
  "main": "index.js",
6
6
  "scripts": {