Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mafintosh/gunzip-maybe
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4.1
Choose a base ref
...
head repository: mafintosh/gunzip-maybe
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.4.2
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Apr 22, 2020

  1. Fix maxRecursion functionality (#8)

    * Test maxRecursion parameter
    
    * Don't reset maxRecursion when recursing
    
    * Fixed test formatting
    sth authored Apr 22, 2020
    Copy the full SHA
    506e753 View commit details
  2. 1.4.2

    mafintosh committed Apr 22, 2020
    Copy the full SHA
    6903d9c View commit details
Showing with 16 additions and 2 deletions.
  1. +1 −1 index.js
  2. +1 −1 package.json
  3. +14 −0 test.js
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ var isCompressed = function (data) {
}

var gunzip = function (maxRecursion) {
if (!(maxRecursion >= 0)) maxRecursion = 3
if (maxRecursion === undefined) maxRecursion = 3

return peek({newline: false, maxBuffer: 10}, function (data, swap) {
if (maxRecursion < 0) return swap(new Error('Maximum recursion reached'))
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gunzip-maybe",
"description": "Transform stream that gunzips its input if it is gzipped and just echoes it if not",
"version": "1.4.1",
"version": "1.4.2",
"repository": {
"type": "git",
"url": "https://github.com/mafintosh/gunzip-maybe"
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -54,3 +54,17 @@ tape('regular input', function (t) {
t.end()
}))
})

tape('limited recursion', function (t) {
t.plan(1)
fs.createReadStream(__filename)
.pipe(zlib.createGzip())
.pipe(zlib.createGzip())
.pipe(gunzip(1))
.on('finish', function () {
t.fail('should not finish')
})
.on('error', function (err) {
t.same(err.message, 'Maximum recursion reached')
})
})