fetch-cookie
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -5,7 +5,10 @@ module.exports = function nodeFetchCookieDecorator (nodeFetch, jar) { | ||
return function nodeFetchCookie (url, opts) { | ||
opts = Object.assign({}, opts, { redirect: 'manual' }) | ||
// Forward identical options to wrapped node-fetch but tell to not handle redirection. | ||
return fetchCookie(url, Object.assign({}, opts, { redirect: 'manual' })) | ||
.then(function (res) { | ||
return fetchCookie(url, opts) | ||
.then(res => { | ||
var isRedirect = (res.status === 303 || ((res.status === 301 || res.status === 302) && opts.method === 'POST')) | ||
// interpret the proprietary "redirect" option in the same way that node-fetch does | ||
// Interpret the proprietary "redirect" option in the same way that node-fetch does. | ||
if (isRedirect && opts.redirect !== 'manual' && opts.follow !== 0) { | ||
@@ -15,6 +18,7 @@ var optsForGet = Object.assign({}, { | ||
body: null, | ||
// since the "follow" flag is not relevant for node-fetch in this case, | ||
// we'll hijack it for our internal bookkeeping | ||
// Since the "follow" flag is not relevant for node-fetch in this case, | ||
// we'll hijack it for our internal bookkeeping. | ||
follow: opts.follow !== undefined ? opts.follow - 1 : undefined | ||
}) | ||
return nodeFetchCookie(res.headers.get('location'), optsForGet) | ||
@@ -21,0 +25,0 @@ } else { |
{ | ||
"name": "fetch-cookie", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Decorator for a `fetch` function to support automatic cookies.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/valeriangalliat/fetch-cookie", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5811
52