Skip to content

Commit

Permalink
Allow passing empty bodies for "void" headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Page- committed Jul 5, 2023
1 parent 93ab386 commit ae88b03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pack.js
Expand Up @@ -73,7 +73,10 @@ class Sink extends Writable {
}

if (this._isVoid) {
return cb(new Error('No body allowed for this entry'))
if (data.byteLength > 0) {
return cb(new Error('No body allowed for this entry'))
}
return cb()
}

this.written += data.byteLength
Expand Down
23 changes: 23 additions & 0 deletions test/pack.js
Expand Up @@ -124,6 +124,29 @@ test('types', function (t) {
}))
})

test('empty directory body is valid', function (t) {
t.plan(1)

const pack = tar.pack()

pack.entry({
name: 'directory',
mtime: new Date(1387580181000),
type: 'directory',
mode: 0o755,
uname: 'maf',
gname: 'staff',
uid: 501,
gid: 20
}, '')

pack.finalize()

pack.resume()

t.pass()
})

test('long-name', function (t) {
t.plan(2)

Expand Down

0 comments on commit ae88b03

Please sign in to comment.