tar 5.0.5 → 5.0.9
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/extract.js +4 -3
- package/lib/list.js +4 -3
- package/lib/mkdir.js +55 -48
- package/lib/normalize-windows-path.js +8 -0
- package/lib/pack.js +8 -18
- package/lib/path-reservations.js +6 -3
- package/lib/read-entry.js +4 -3
- package/lib/replace.js +2 -1
- package/lib/strip-absolute-path.js +14 -0
- package/lib/strip-trailing-slashes.js +24 -0
- package/lib/unpack.js +213 -83
- package/lib/write-entry.js +165 -72
- package/package.json +15 -9
package/lib/extract.js
CHANGED
|
@@ -6,6 +6,7 @@ const Unpack = require('./unpack.js')
|
|
|
6
6
|
const fs = require('fs')
|
|
7
7
|
const fsm = require('fs-minipass')
|
|
8
8
|
const path = require('path')
|
|
9
|
+
const stripSlash = require('./strip-trailing-slashes.js')
|
|
9
10
|
|
|
10
11
|
const x = module.exports = (opt_, files, cb) => {
|
|
11
12
|
if (typeof opt_ === 'function')
|
|
@@ -41,7 +42,7 @@ const x = module.exports = (opt_, files, cb) => {
|
|
|
41
42
|
// construct a filter that limits the file entries listed
|
|
42
43
|
// include child entries if a dir is included
|
|
43
44
|
const filesFilter = (opt, files) => {
|
|
44
|
-
const map = new Map(files.map(f => [f
|
|
45
|
+
const map = new Map(files.map(f => [stripSlash(f), true]))
|
|
45
46
|
const filter = opt.filter
|
|
46
47
|
|
|
47
48
|
const mapHas = (file, r) => {
|
|
@@ -55,8 +56,8 @@ const filesFilter = (opt, files) => {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
opt.filter = filter
|
|
58
|
-
? (file, entry) => filter(file, entry) && mapHas(file
|
|
59
|
-
: file => mapHas(file
|
|
59
|
+
? (file, entry) => filter(file, entry) && mapHas(stripSlash(file))
|
|
60
|
+
: file => mapHas(stripSlash(file))
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const extractFileSync = opt => {
|
package/lib/list.js
CHANGED
|
@@ -9,6 +9,7 @@ const Parser = require('./parse.js')
|
|
|
9
9
|
const fs = require('fs')
|
|
10
10
|
const fsm = require('fs-minipass')
|
|
11
11
|
const path = require('path')
|
|
12
|
+
const stripSlash = require('./strip-trailing-slashes.js')
|
|
12
13
|
|
|
13
14
|
const t = module.exports = (opt_, files, cb) => {
|
|
14
15
|
if (typeof opt_ === 'function')
|
|
@@ -54,7 +55,7 @@ const onentryFunction = opt => {
|
|
|
54
55
|
// construct a filter that limits the file entries listed
|
|
55
56
|
// include child entries if a dir is included
|
|
56
57
|
const filesFilter = (opt, files) => {
|
|
57
|
-
const map = new Map(files.map(f => [f
|
|
58
|
+
const map = new Map(files.map(f => [stripSlash(f), true]))
|
|
58
59
|
const filter = opt.filter
|
|
59
60
|
|
|
60
61
|
const mapHas = (file, r) => {
|
|
@@ -68,8 +69,8 @@ const filesFilter = (opt, files) => {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
opt.filter = filter
|
|
71
|
-
? (file, entry) => filter(file, entry) && mapHas(file
|
|
72
|
-
: file => mapHas(file
|
|
72
|
+
? (file, entry) => filter(file, entry) && mapHas(stripSlash(file))
|
|
73
|
+
: file => mapHas(stripSlash(file))
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
const listFileSync = opt => {
|
package/lib/mkdir.js
CHANGED
|
@@ -8,6 +8,7 @@ const mkdirp = require('mkdirp')
|
|
|
8
8
|
const fs = require('fs')
|
|
9
9
|
const path = require('path')
|
|
10
10
|
const chownr = require('chownr')
|
|
11
|
+
const normPath = require('./normalize-windows-path.js')
|
|
11
12
|
|
|
12
13
|
class SymlinkError extends Error {
|
|
13
14
|
constructor (symlink, path) {
|
|
@@ -33,7 +34,20 @@ class CwdError extends Error {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
const
|
|
37
|
+
const cGet = (cache, key) => cache.get(normPath(key))
|
|
38
|
+
const cSet = (cache, key, val) => cache.set(normPath(key), val)
|
|
39
|
+
|
|
40
|
+
const checkCwd = (dir, cb) => {
|
|
41
|
+
fs.stat(dir, (er, st) => {
|
|
42
|
+
if (er || !st.isDirectory())
|
|
43
|
+
er = new CwdError(dir, er && er.code || 'ENOTDIR')
|
|
44
|
+
cb(er)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = (dir, opt, cb) => {
|
|
49
|
+
dir = normPath(dir)
|
|
50
|
+
|
|
37
51
|
// if there's any overlap between mask and mode,
|
|
38
52
|
// then we'll need an explicit chmod
|
|
39
53
|
const umask = opt.umask
|
|
@@ -49,13 +63,13 @@ const mkdir = module.exports = (dir, opt, cb) => {
|
|
|
49
63
|
const preserve = opt.preserve
|
|
50
64
|
const unlink = opt.unlink
|
|
51
65
|
const cache = opt.cache
|
|
52
|
-
const cwd = opt.cwd
|
|
66
|
+
const cwd = normPath(opt.cwd)
|
|
53
67
|
|
|
54
68
|
const done = (er, created) => {
|
|
55
69
|
if (er)
|
|
56
70
|
cb(er)
|
|
57
71
|
else {
|
|
58
|
-
cache
|
|
72
|
+
cSet(cache, dir, true)
|
|
59
73
|
if (created && doChown)
|
|
60
74
|
chownr(created, uid, gid, er => done(er))
|
|
61
75
|
else if (needChmod)
|
|
@@ -65,21 +79,17 @@ const mkdir = module.exports = (dir, opt, cb) => {
|
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
if (cache && cache
|
|
82
|
+
if (cache && cGet(cache, dir) === true)
|
|
69
83
|
return done()
|
|
70
84
|
|
|
71
85
|
if (dir === cwd)
|
|
72
|
-
return
|
|
73
|
-
if (er || !st.isDirectory())
|
|
74
|
-
er = new CwdError(dir, er && er.code || 'ENOTDIR')
|
|
75
|
-
done(er)
|
|
76
|
-
})
|
|
86
|
+
return checkCwd(dir, done)
|
|
77
87
|
|
|
78
88
|
if (preserve)
|
|
79
89
|
return mkdirp(dir, mode, done)
|
|
80
90
|
|
|
81
|
-
const sub = path.relative(cwd, dir)
|
|
82
|
-
const parts = sub.split(
|
|
91
|
+
const sub = normPath(path.relative(cwd, dir))
|
|
92
|
+
const parts = sub.split('/')
|
|
83
93
|
mkdir_(cwd, parts, mode, cache, unlink, cwd, null, done)
|
|
84
94
|
}
|
|
85
95
|
|
|
@@ -87,22 +97,19 @@ const mkdir_ = (base, parts, mode, cache, unlink, cwd, created, cb) => {
|
|
|
87
97
|
if (!parts.length)
|
|
88
98
|
return cb(null, created)
|
|
89
99
|
const p = parts.shift()
|
|
90
|
-
const part = base + '/' + p
|
|
91
|
-
if (cache
|
|
100
|
+
const part = normPath(path.resolve(base + '/' + p))
|
|
101
|
+
if (cGet(cache, part))
|
|
92
102
|
return mkdir_(part, parts, mode, cache, unlink, cwd, created, cb)
|
|
93
103
|
fs.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb))
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
const onmkdir = (part, parts, mode, cache, unlink, cwd, created, cb) => er => {
|
|
97
107
|
if (er) {
|
|
98
|
-
if (er.path && path.dirname(er.path) === cwd &&
|
|
99
|
-
(er.code === 'ENOTDIR' || er.code === 'ENOENT'))
|
|
100
|
-
return cb(new CwdError(cwd, er.code))
|
|
101
|
-
|
|
102
108
|
fs.lstat(part, (statEr, st) => {
|
|
103
|
-
if (statEr)
|
|
109
|
+
if (statEr) {
|
|
110
|
+
statEr.path = statEr.path && normPath(statEr.path)
|
|
104
111
|
cb(statEr)
|
|
105
|
-
else if (st.isDirectory())
|
|
112
|
+
} else if (st.isDirectory())
|
|
106
113
|
mkdir_(part, parts, mode, cache, unlink, cwd, created, cb)
|
|
107
114
|
else if (unlink)
|
|
108
115
|
fs.unlink(part, er => {
|
|
@@ -121,7 +128,21 @@ const onmkdir = (part, parts, mode, cache, unlink, cwd, created, cb) => er => {
|
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
const
|
|
131
|
+
const checkCwdSync = dir => {
|
|
132
|
+
let ok = false
|
|
133
|
+
let code = 'ENOTDIR'
|
|
134
|
+
try {
|
|
135
|
+
ok = fs.statSync(dir).isDirectory()
|
|
136
|
+
} catch (er) {
|
|
137
|
+
code = er.code
|
|
138
|
+
} finally {
|
|
139
|
+
if (!ok)
|
|
140
|
+
throw new CwdError(dir, code)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports.sync = (dir, opt) => {
|
|
145
|
+
dir = normPath(dir)
|
|
125
146
|
// if there's any overlap between mask and mode,
|
|
126
147
|
// then we'll need an explicit chmod
|
|
127
148
|
const umask = opt.umask
|
|
@@ -137,65 +158,51 @@ const mkdirSync = module.exports.sync = (dir, opt) => {
|
|
|
137
158
|
const preserve = opt.preserve
|
|
138
159
|
const unlink = opt.unlink
|
|
139
160
|
const cache = opt.cache
|
|
140
|
-
const cwd = opt.cwd
|
|
161
|
+
const cwd = normPath(opt.cwd)
|
|
141
162
|
|
|
142
163
|
const done = (created) => {
|
|
143
|
-
cache
|
|
164
|
+
cSet(cache, dir, true)
|
|
144
165
|
if (created && doChown)
|
|
145
166
|
chownr.sync(created, uid, gid)
|
|
146
167
|
if (needChmod)
|
|
147
168
|
fs.chmodSync(dir, mode)
|
|
148
169
|
}
|
|
149
170
|
|
|
150
|
-
if (cache && cache
|
|
171
|
+
if (cache && cGet(cache, dir) === true)
|
|
151
172
|
return done()
|
|
152
173
|
|
|
153
174
|
if (dir === cwd) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
ok = fs.statSync(dir).isDirectory()
|
|
158
|
-
} catch (er) {
|
|
159
|
-
code = er.code
|
|
160
|
-
} finally {
|
|
161
|
-
if (!ok)
|
|
162
|
-
throw new CwdError(dir, code)
|
|
163
|
-
}
|
|
164
|
-
done()
|
|
165
|
-
return
|
|
175
|
+
checkCwdSync(cwd)
|
|
176
|
+
return done()
|
|
166
177
|
}
|
|
167
178
|
|
|
168
179
|
if (preserve)
|
|
169
180
|
return done(mkdirp.sync(dir, mode))
|
|
170
181
|
|
|
171
|
-
const sub = path.relative(cwd, dir)
|
|
172
|
-
const parts = sub.split(
|
|
182
|
+
const sub = normPath(path.relative(cwd, dir))
|
|
183
|
+
const parts = sub.split('/')
|
|
173
184
|
let created = null
|
|
174
185
|
for (let p = parts.shift(), part = cwd;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (cache
|
|
186
|
+
p && (part += '/' + p);
|
|
187
|
+
p = parts.shift()) {
|
|
188
|
+
part = normPath(path.resolve(part))
|
|
189
|
+
if (cGet(cache, part))
|
|
179
190
|
continue
|
|
180
191
|
|
|
181
192
|
try {
|
|
182
193
|
fs.mkdirSync(part, mode)
|
|
183
194
|
created = created || part
|
|
184
|
-
cache
|
|
195
|
+
cSet(cache, part, true)
|
|
185
196
|
} catch (er) {
|
|
186
|
-
if (er.path && path.dirname(er.path) === cwd &&
|
|
187
|
-
(er.code === 'ENOTDIR' || er.code === 'ENOENT'))
|
|
188
|
-
return new CwdError(cwd, er.code)
|
|
189
|
-
|
|
190
197
|
const st = fs.lstatSync(part)
|
|
191
198
|
if (st.isDirectory()) {
|
|
192
|
-
cache
|
|
199
|
+
cSet(cache, part, true)
|
|
193
200
|
continue
|
|
194
201
|
} else if (unlink) {
|
|
195
202
|
fs.unlinkSync(part)
|
|
196
203
|
fs.mkdirSync(part, mode)
|
|
197
204
|
created = created || part
|
|
198
|
-
cache
|
|
205
|
+
cSet(cache, part, true)
|
|
199
206
|
continue
|
|
200
207
|
} else if (st.isSymbolicLink())
|
|
201
208
|
return new SymlinkError(part, part + '/' + parts.join('/'))
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// on windows, either \ or / are valid directory separators.
|
|
2
|
+
// on unix, \ is a valid character in filenames.
|
|
3
|
+
// so, on windows, and only on windows, we replace all \ chars with /,
|
|
4
|
+
// so that we can use / as our one and only directory separator char.
|
|
5
|
+
|
|
6
|
+
const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform
|
|
7
|
+
module.exports = platform !== 'win32' ? p => p
|
|
8
|
+
: p => p && p.replace(/\\/g, '/')
|
package/lib/pack.js
CHANGED
|
@@ -54,6 +54,7 @@ const ONDRAIN = Symbol('ondrain')
|
|
|
54
54
|
const fs = require('fs')
|
|
55
55
|
const path = require('path')
|
|
56
56
|
const warner = require('./warn-mixin.js')
|
|
57
|
+
const normPath = require('./normalize-windows-path.js')
|
|
57
58
|
|
|
58
59
|
const Pack = warner(class Pack extends MiniPass {
|
|
59
60
|
constructor (opt) {
|
|
@@ -66,7 +67,7 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
66
67
|
this.preservePaths = !!opt.preservePaths
|
|
67
68
|
this.strict = !!opt.strict
|
|
68
69
|
this.noPax = !!opt.noPax
|
|
69
|
-
this.prefix = (opt.prefix || '')
|
|
70
|
+
this.prefix = normPath(opt.prefix || '')
|
|
70
71
|
this.linkCache = opt.linkCache || new Map()
|
|
71
72
|
this.statCache = opt.statCache || new Map()
|
|
72
73
|
this.readdirCache = opt.readdirCache || new Map()
|
|
@@ -133,10 +134,7 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
[ADDTARENTRY] (p) {
|
|
136
|
-
const absolute = path.resolve(this.cwd, p.path)
|
|
137
|
-
if (this.prefix)
|
|
138
|
-
p.path = this.prefix + '/' + p.path.replace(/^\.(\/+|$)/, '')
|
|
139
|
-
|
|
137
|
+
const absolute = normPath(path.resolve(this.cwd, p.path))
|
|
140
138
|
// in this case, we don't have to wait for the stat
|
|
141
139
|
if (!this.filter(p.path, p))
|
|
142
140
|
p.resume()
|
|
@@ -152,10 +150,7 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
[ADDFSENTRY] (p) {
|
|
155
|
-
const absolute = path.resolve(this.cwd, p)
|
|
156
|
-
if (this.prefix)
|
|
157
|
-
p = this.prefix + '/' + p.replace(/^\.(\/+|$)/, '')
|
|
158
|
-
|
|
153
|
+
const absolute = normPath(path.resolve(this.cwd, p))
|
|
159
154
|
this[QUEUE].push(new PackJob(p, absolute))
|
|
160
155
|
this[PROCESS]()
|
|
161
156
|
}
|
|
@@ -297,7 +292,8 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
297
292
|
linkCache: this.linkCache,
|
|
298
293
|
statCache: this.statCache,
|
|
299
294
|
noMtime: this.noMtime,
|
|
300
|
-
mtime: this.mtime
|
|
295
|
+
mtime: this.mtime,
|
|
296
|
+
prefix: this.prefix,
|
|
301
297
|
}
|
|
302
298
|
}
|
|
303
299
|
|
|
@@ -323,10 +319,7 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
323
319
|
|
|
324
320
|
if (job.readdir)
|
|
325
321
|
job.readdir.forEach(entry => {
|
|
326
|
-
const p =
|
|
327
|
-
job.path.slice(this.prefix.length + 1) || './'
|
|
328
|
-
: job.path
|
|
329
|
-
|
|
322
|
+
const p = job.path
|
|
330
323
|
const base = p === './' ? '' : p.replace(/\/*$/, '/')
|
|
331
324
|
this[ADDFSENTRY](base + entry)
|
|
332
325
|
})
|
|
@@ -379,10 +372,7 @@ class PackSync extends Pack {
|
|
|
379
372
|
|
|
380
373
|
if (job.readdir)
|
|
381
374
|
job.readdir.forEach(entry => {
|
|
382
|
-
const p =
|
|
383
|
-
job.path.slice(this.prefix.length + 1) || './'
|
|
384
|
-
: job.path
|
|
385
|
-
|
|
375
|
+
const p = job.path
|
|
386
376
|
const base = p === './' ? '' : p.replace(/\/*$/, '/')
|
|
387
377
|
this[ADDFSENTRY](base + entry)
|
|
388
378
|
})
|
package/lib/path-reservations.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
// while still allowing maximal safe parallelization.
|
|
8
8
|
|
|
9
9
|
const assert = require('assert')
|
|
10
|
+
const normPath = require('./normalize-windows-path.js')
|
|
11
|
+
const { join } = require('path')
|
|
10
12
|
|
|
11
13
|
module.exports = () => {
|
|
12
14
|
// path => [function or Set]
|
|
@@ -18,10 +20,10 @@ module.exports = () => {
|
|
|
18
20
|
const reservations = new Map()
|
|
19
21
|
|
|
20
22
|
// return a set of parent dirs for a given path
|
|
21
|
-
const { join } = require('path')
|
|
22
23
|
const getDirs = path =>
|
|
23
|
-
|
|
24
|
-
set.length ? set.concat(join(set[set.length-1], path))
|
|
24
|
+
path.split('/').slice(0, -1).reduce((set, path) =>
|
|
25
|
+
set.length ? set.concat(normPath(join(set[set.length - 1], path)))
|
|
26
|
+
: [path], [])
|
|
25
27
|
|
|
26
28
|
// functions currently running
|
|
27
29
|
const running = new Set()
|
|
@@ -97,6 +99,7 @@ module.exports = () => {
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
const reserve = (paths, fn) => {
|
|
102
|
+
paths = paths.map(p => normPath(join(p)).toLowerCase())
|
|
100
103
|
const dirs = new Set(
|
|
101
104
|
paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b))
|
|
102
105
|
)
|
package/lib/read-entry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const types = require('./types.js')
|
|
3
3
|
const MiniPass = require('minipass')
|
|
4
|
+
const normPath = require('./normalize-windows-path.js')
|
|
4
5
|
|
|
5
6
|
const SLURP = Symbol('slurp')
|
|
6
7
|
module.exports = class ReadEntry extends MiniPass {
|
|
@@ -47,7 +48,7 @@ module.exports = class ReadEntry extends MiniPass {
|
|
|
47
48
|
this.ignore = true
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
this.path = header.path
|
|
51
|
+
this.path = normPath(header.path)
|
|
51
52
|
this.mode = header.mode
|
|
52
53
|
if (this.mode)
|
|
53
54
|
this.mode = this.mode & 0o7777
|
|
@@ -59,7 +60,7 @@ module.exports = class ReadEntry extends MiniPass {
|
|
|
59
60
|
this.mtime = header.mtime
|
|
60
61
|
this.atime = header.atime
|
|
61
62
|
this.ctime = header.ctime
|
|
62
|
-
this.linkpath = header.linkpath
|
|
63
|
+
this.linkpath = normPath(header.linkpath)
|
|
63
64
|
this.uname = header.uname
|
|
64
65
|
this.gname = header.gname
|
|
65
66
|
|
|
@@ -92,7 +93,7 @@ module.exports = class ReadEntry extends MiniPass {
|
|
|
92
93
|
// a global extended header, because that's weird.
|
|
93
94
|
if (ex[k] !== null && ex[k] !== undefined &&
|
|
94
95
|
!(global && k === 'path'))
|
|
95
|
-
this[k] = ex[k]
|
|
96
|
+
this[k] = k === 'path' || k === 'linkpath' ? normPath(ex[k]) : ex[k]
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
}
|
package/lib/replace.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// unix absolute paths are also absolute on win32, so we use this for both
|
|
2
|
+
const { isAbsolute, parse } = require('path').win32
|
|
3
|
+
|
|
4
|
+
// returns [root, stripped]
|
|
5
|
+
module.exports = path => {
|
|
6
|
+
let r = ''
|
|
7
|
+
while (isAbsolute(path)) {
|
|
8
|
+
// windows will think that //x/y/z has a "root" of //x/y/
|
|
9
|
+
const root = path.charAt(0) === '/' ? '/' : parse(path).root
|
|
10
|
+
path = path.substr(root.length)
|
|
11
|
+
r += root
|
|
12
|
+
}
|
|
13
|
+
return [r, path]
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// this is the only approach that was significantly faster than using
|
|
2
|
+
// str.replace(/\/+$/, '') for strings ending with a lot of / chars and
|
|
3
|
+
// containing multiple / chars.
|
|
4
|
+
const batchStrings = [
|
|
5
|
+
'/'.repeat(1024),
|
|
6
|
+
'/'.repeat(512),
|
|
7
|
+
'/'.repeat(256),
|
|
8
|
+
'/'.repeat(128),
|
|
9
|
+
'/'.repeat(64),
|
|
10
|
+
'/'.repeat(32),
|
|
11
|
+
'/'.repeat(16),
|
|
12
|
+
'/'.repeat(8),
|
|
13
|
+
'/'.repeat(4),
|
|
14
|
+
'/'.repeat(2),
|
|
15
|
+
'/',
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
module.exports = str => {
|
|
19
|
+
for (const s of batchStrings) {
|
|
20
|
+
while (str.length >= s.length && str.slice(-1 * s.length) === s)
|
|
21
|
+
str = str.slice(0, -1 * s.length)
|
|
22
|
+
}
|
|
23
|
+
return str
|
|
24
|
+
}
|