Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

follow-redirects

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

follow-redirects - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

test/issue-7.js

20

index.js
var nativeHttps = require('https'),
nativeHttp = require('http'),
url = require('url'),
_ = require('underscore');
_ = require('underscore'),
debug = require('debug')('follow-redirects');

@@ -50,3 +51,3 @@ var maxRedirects = module.exports.maxRedirects = 5;

*/
var reqUrl;
var reqUrl, method;
if (typeof options === 'string') {

@@ -62,2 +63,3 @@ reqUrl = options;

*/
debug(options);
var clientRequest = h.__proto__.request(options, redirectCallback(reqUrl, redirect));

@@ -72,3 +74,6 @@

function redirectCallback (reqUrl, redirect) {
debug('redirectCallback');
return function (res) {
debug('headers:');
debug(res.headers);
// status must be 300-399 for redirects

@@ -92,2 +97,3 @@ if (res.statusCode < 300 || res.statusCode > 399) {

var redirectUrl = url.resolve(reqUrl, res.headers['location']);
debug('redirectUrl', redirectUrl);
// we need to call the right api (http vs https) depending on protocol

@@ -99,7 +105,8 @@ var proto = url.parse(redirectUrl).protocol;

// Break url in parts
var searchname = url.parse(redirectUrl).search;
var hostname = url.parse(redirectUrl).hostname;
var pathname = url.parse(redirectUrl).pathname;
var parsedUrl = url.parse(redirectUrl);
var searchname = parsedUrl.search || '';
var hostname = parsedUrl.hostname;
var pathname = parsedUrl.pathname;
var redirectOptions = options;
var redirectOptions = typeof options === 'string' ? {} : options;
redirectOptions.reqUrl = redirectUrl;

@@ -109,2 +116,3 @@ redirectOptions.hostname = hostname;

debug('redirectOptions', redirectOptions);
var out = module.exports[proto].get(redirectOptions, redirectCallback(reqUrl, redirect), redirect);

@@ -111,0 +119,0 @@

{
"name": "follow-redirects",
"version": "0.0.4",
"version": "0.0.5",
"description": "HTTP and HTTPS modules that follow redirects.",

@@ -24,7 +24,8 @@ "main": "index.js",

"author": {
"name": "Olivier Lalonde"
, "email": "olalonde@gmail.com"
, "url": "http://www.syskall.com"
"name": "Olivier Lalonde",
"email": "olalonde@gmail.com",
"url": "http://www.syskall.com"
},
"dependencies": {
"debug": "^2.2.0",
"underscore": ""

@@ -31,0 +32,0 @@ },

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