Socket
Socket
Sign inDemoInstall

fetch-cookie

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-cookie - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

14

node-fetch.js

@@ -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",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc