Skip to content

Commit 280ab0d

Browse files
committed
fix: ci
1 parent 957376b commit 280ab0d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ exports.makeUncompressFn = StreamClass => {
8989
}
9090

9191
const strip = opts.strip ? Number(opts.strip) : 0;
92+
// Strip is handled here in makeUncompressFn, so remove it from opts to avoid passing to UncompressStream
93+
delete opts.strip;
9294

9395
return new Promise((resolve, reject) => {
9496
fs.mkdir(destDir, { recursive: true }, err => {

lib/zip/uncompress_stream.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const utils = require('../utils');
1212
let iconv;
1313

1414
const YAUZL_CALLBACK = Symbol('ZipUncompressStream#yauzlCallback');
15+
const STRIP_NAME = Symbol('ZipUncompressStream#stripName');
1516

1617
// don't decodeStrings on yauzl, we should handle fileName by ourself
1718
// see validateFileName on https://github.com/thejoshwolfe/yauzl/blob/51010ce4e8c7e6345efe195e1b4150518f37b393/index.js#L607
@@ -33,6 +34,7 @@ class ZipUncompressStream extends UncompressBaseStream {
3334
super(opts);
3435

3536
this._chunks = [];
37+
this._strip = Number(opts.strip) || 0;
3638
this._zipFileNameEncoding = opts.zipFileNameEncoding || 'utf8';
3739
if (this._zipFileNameEncoding === 'utf-8') {
3840
this._zipFileNameEncoding = 'utf8';
@@ -106,7 +108,7 @@ class ZipUncompressStream extends UncompressBaseStream {
106108
}
107109
// directory file names end with '/' (for Linux and macOS) or '\' (for Windows)
108110
const type = /[\\\/]$/.test(entry.fileName) ? 'directory' : 'file';
109-
const name = entry.fileName;
111+
const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
110112

111113
const header = { name, type, yauzl: entry, mode };
112114

@@ -133,6 +135,10 @@ class ZipUncompressStream extends UncompressBaseStream {
133135
zipFile.readEntry();
134136
}
135137
}
138+
139+
[STRIP_NAME](fileName, type) {
140+
return utils.stripFileName(this._strip, fileName, type);
141+
}
136142
}
137143

138144
module.exports = ZipUncompressStream;

0 commit comments

Comments
 (0)