diff --git a/lib/create.js b/lib/create.js index e5c4383f..9c860d4e 100644 --- a/lib/create.js +++ b/lib/create.js @@ -70,7 +70,7 @@ const addFilesSync = (p, files) => { files.forEach(file => { if (file.charAt(0) === '@') { t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), sync: true, noResume: true, onentry: entry => p.add(entry), @@ -87,7 +87,7 @@ const addFilesAsync = (p, files) => { const file = files.shift() if (file.charAt(0) === '@') { return t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), noResume: true, onentry: entry => p.add(entry), }).then(_ => addFilesAsync(p, files)) diff --git a/lib/header.js b/lib/header.js index 194550dd..411d5e45 100644 --- a/lib/header.js +++ b/lib/header.js @@ -68,7 +68,7 @@ class Header { if (this[TYPE] === '') { this[TYPE] = '0' } - if (this[TYPE] === '0' && this.path.substr(-1) === '/') { + if (this[TYPE] === '0' && this.path.slice(-1) === '/') { this[TYPE] = '5' } @@ -232,7 +232,7 @@ const splitPrefix = (p, prefixSize) => { } else if (Buffer.byteLength(pp) > pathSize && Buffer.byteLength(prefix) <= prefixSize) { // prefix fits in prefix, but path doesn't fit in path - ret = [pp.substr(0, pathSize - 1), prefix, true] + ret = [pp.slice(0, pathSize - 1), prefix, true] } else { // make path take a bit from prefix pp = pathModule.join(pathModule.basename(prefix), pp) @@ -242,7 +242,7 @@ const splitPrefix = (p, prefixSize) => { // at this point, found no resolution, just truncate if (!ret) { - ret = [p.substr(0, pathSize - 1), '', true] + ret = [p.slice(0, pathSize - 1), '', true] } } return ret diff --git a/lib/pax.js b/lib/pax.js index a505c1ab..4a7ca853 100644 --- a/lib/pax.js +++ b/lib/pax.js @@ -132,7 +132,7 @@ const parseKVLine = (set, line) => { return set } - line = line.substr((n + ' ').length) + line = line.slice((n + ' ').length) const kv = line.split('=') const k = kv.shift().replace(/^SCHILY\.(dev|ino|nlink)/, '$1') if (!k) { diff --git a/lib/replace.js b/lib/replace.js index 60d07375..c6e619be 100644 --- a/lib/replace.js +++ b/lib/replace.js @@ -217,7 +217,7 @@ const addFilesSync = (p, files) => { files.forEach(file => { if (file.charAt(0) === '@') { t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), sync: true, noResume: true, onentry: entry => p.add(entry), @@ -234,7 +234,7 @@ const addFilesAsync = (p, files) => { const file = files.shift() if (file.charAt(0) === '@') { return t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), noResume: true, onentry: entry => p.add(entry), }).then(_ => addFilesAsync(p, files)) diff --git a/lib/strip-absolute-path.js b/lib/strip-absolute-path.js index 1aa2d2ae..185e2dea 100644 --- a/lib/strip-absolute-path.js +++ b/lib/strip-absolute-path.js @@ -16,7 +16,7 @@ module.exports = path => { // but strip the //?/C:/ off of //?/C:/path const root = path.charAt(0) === '/' && path.slice(0, 4) !== '//?/' ? '/' : parsed.root - path = path.substr(root.length) + path = path.slice(root.length) r += root parsed = parse(path) } diff --git a/lib/unpack.js b/lib/unpack.js index 458f593d..6d9132c2 100644 --- a/lib/unpack.js +++ b/lib/unpack.js @@ -311,9 +311,9 @@ class Unpack extends Parser { // only encode : chars that aren't drive letter indicators if (this.win32) { const { root: aRoot } = path.win32.parse(entry.absolute) - entry.absolute = aRoot + wc.encode(entry.absolute.substr(aRoot.length)) + entry.absolute = aRoot + wc.encode(entry.absolute.slice(aRoot.length)) const { root: pRoot } = path.win32.parse(entry.path) - entry.path = pRoot + wc.encode(entry.path.substr(pRoot.length)) + entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length)) } return true diff --git a/lib/write-entry.js b/lib/write-entry.js index cad969ff..3b5540f7 100644 --- a/lib/write-entry.js +++ b/lib/write-entry.js @@ -205,7 +205,7 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { } [DIRECTORY] () { - if (this.path.substr(-1) !== '/') { + if (this.path.slice(-1) !== '/') { this.path += '/' } this.stat.size = 0 diff --git a/test/unpack.js b/test/unpack.js index 0b8d7231..b23aab3d 100644 --- a/test/unpack.js +++ b/test/unpack.js @@ -800,7 +800,7 @@ t.test('absolute paths', t => { t.ok(path.isAbsolute(extraAbsolute)) t.ok(path.isAbsolute(absolute)) const parsed = path.parse(absolute) - const relative = absolute.substr(parsed.root.length) + const relative = absolute.slice(parsed.root.length) t.notOk(path.isAbsolute(relative)) const data = makeTar([ diff --git a/test/write-entry.js b/test/write-entry.js index 4cad6969..b72e53a1 100644 --- a/test/write-entry.js +++ b/test/write-entry.js @@ -691,7 +691,7 @@ t.test('win32 <|>? in paths', { wc.on('data', c => out.push(c)) wc.on('end', _ => { const data = Buffer.concat(out).toString() - t.equal(data.substr(0, 4), '<|>?') + t.equal(data.slice(0, 4), '<|>?') t.end() })