@zeit/fetch-cached-dns
Advanced tools
Comparing version 1.0.2 to 1.0.3
1.0.3 / 2017-11-16 | ||
================== | ||
* fix `headers` as a regular Object | ||
1.0.2 / 2017-11-16 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -20,3 +20,3 @@ const { isIP } = require('net') | ||
if (!opts) opts = {} | ||
if (!opts.headers) opts.headers = new Headers() | ||
opts.headers = new Headers(opts.headers) | ||
if (!opts.headers.has('Host')) { | ||
@@ -32,3 +32,3 @@ opts.headers.set('Host', parsed.host) | ||
const redirectOpts = Object.assign({}, opts) | ||
if (!redirectOpts.headers) redirectOpts.headers = new Headers() | ||
redirectOpts.headers = new Headers(opts.headers) | ||
@@ -35,0 +35,0 @@ // per fetch spec, for POST request with 301/302 response, or any request with 303 response, use GET when following redirect |
{ | ||
"name": "@zeit/fetch-cached-dns", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A decorator on top of `fetch` that caches the DNS query of the `hostname` of the passed URL", | ||
@@ -5,0 +5,0 @@ "scripts": { |
17
test.js
@@ -50,1 +50,18 @@ /* eslint-env jest*/ | ||
}) | ||
test('works with `headers` as an Object', async () => { | ||
const server = createServer((req, res) => { | ||
res.end(req.headers['x-zeit']) | ||
}) | ||
await listen(server) | ||
const { port } = server.address() | ||
const res = await cachedDNSFetch(`http://localtest.me:${port}`, { | ||
headers: { | ||
'X-Zeit': 'geist' | ||
} | ||
}) | ||
expect(await res.text()).toBe('geist') | ||
server.close() | ||
}) |
113795
103