Socket
Socket
Sign inDemoInstall

@zeit/fetch-cached-dns

Package Overview
Dependencies
12
Maintainers
18
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

2

index.js

@@ -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()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc