Skip to content

Commit

Permalink
fix: fix packument unzip
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Nov 10, 2022
1 parent 34b0243 commit 6f236d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/js/firewall/middleware.js
@@ -1,7 +1,7 @@
import {httpError, NOT_FOUND, ACCESS_DENIED, METHOD_NOT_ALLOWED, NOT_MODIFIED, OK, FOUND} from '../http/index.js'
import {getPolicy, getPipeline} from './engine.js'
import {getPackument} from './packument.js'
import {normalizePath, gzip, dropNullEntries, time} from '../util.js'
import {normalizePath, gunzip, dropNullEntries, time} from '../util.js'
import {hasHit, hasKey, isNoCache} from '../cache.js'
import {getCtx} from '../als.js'
import {checkTarball} from './tarball.js'
Expand Down Expand Up @@ -95,7 +95,7 @@ export const firewall = ({registry, rules, entrypoint: _entrypoint, token}) => a

// Packument request
const isGzip = req.headers['accept-encoding']?.includes('gzip')
const buffer = isGzip ? await time(gzip, `gzip packument ${name}`)(packumentBuffer) : packumentBuffer
const buffer = isGzip ? packumentBuffer : await time(gunzip, `gunzip packument ${name}`)(packumentBuffer)
const cl = '' + buffer.length
const extra = isGzip
? {'content-length': cl, 'transfer-encoding': null, 'content-encoding': 'gzip', etag}
Expand Down
3 changes: 2 additions & 1 deletion src/test/js/app.js
Expand Up @@ -68,7 +68,7 @@ test('is runnable', async () => {
[
'reads packument via GET',
{ url: 'http://localhost:3001/registry/d', method: 'GET'},
{ statusCode: 200 }
{ statusCode: 200, json: {name: 'd', description: 'Property descriptor factory'}}
],
[
'reads packument via HEAD',
Expand Down Expand Up @@ -119,6 +119,7 @@ test('is runnable', async () => {
result = {
statusCode: res.statusCode,
body: res.body,
json: JSON.parse(res.body || null),
hash,
}
} catch ({statusCode}) {
Expand Down

0 comments on commit 6f236d1

Please sign in to comment.