@zeit/fetch-cached-dns
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -47,3 +47,3 @@ const { isIP } = require('net') | ||
if (opts.onRedirect) { | ||
opts.onRedirect(redirectOpts) | ||
opts.onRedirect(res, redirectOpts) | ||
} | ||
@@ -50,0 +50,0 @@ |
{ | ||
"name": "@zeit/fetch-cached-dns", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A decorator on top of `fetch` that caches the DNS query of the `hostname` of the passed URL", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -12,5 +12,6 @@ # fetch-cached-dns | ||
Since this implementation is implementing redirects we are providing an `onRedirect` extra | ||
option to the `fetch` call that allows one to customize the redirect options just before it | ||
happens. | ||
option to the `fetch` call that gets called with the response object and the options that | ||
will be used for the next request. This allows to access the request from outside and to | ||
modify the options. | ||
*NOTE: if the fetch implementation is not supplied, it will attempt to use peerDep `node-fetch`* |
@@ -110,3 +110,3 @@ /* eslint-env jest*/ | ||
const options = { | ||
onRedirect: jest.fn(opts => { | ||
onRedirect: jest.fn((res, opts) => { | ||
opts.randomOption = true | ||
@@ -118,6 +118,8 @@ }) | ||
expect(options.onRedirect.mock.calls.length).toBe(1) | ||
expect(options.onRedirect.mock.calls[0][0].headers).toBeDefined() | ||
expect(options.onRedirect.mock.calls[0][0].randomOption).toBe(true) | ||
const [res, opts] = options.onRedirect.mock.calls[0] | ||
expect(res.status).toEqual(302) | ||
expect(opts.headers).toBeDefined() | ||
expect(opts.randomOption).toBe(true) | ||
server.close() | ||
}) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
115476
153
17
7