JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 553
  • Score
    100M100P100Q100038F
  • License ISC

A simple command-line utility that lets you follow redirects to see where http URLs end up. Useful for shortened URLs.

Package Exports

  • follow-redirect-url
  • follow-redirect-url/lib.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (follow-redirect-url) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

follow-redirect-url

NPM

Node version npm version Build Status Coverage Dependency Status Known npm Vulnerabilities Known Vulnerabilities Downloads Total Downloads Monthly

A simple command-line utility that lets you follow redirects to see where http URLs end up. Useful for shortened URLs.

Follows up to 20 redirects Default.

Also added User-Agent header to requests, some web address won't redirect without browsers information eg: https://fb.me

Table of contents

Installation

Install with npm globally (For CLI):

npm install -g follow-redirect-url

Install for your project:

npm install -save follow-redirect-url

back to top


Usage

CLI:

follow https://bit.ly/2X7gCIT

Module:

The first argument is a url string.

'use strict';

const followRedirect = require('follow-redirect-url');

followRedirect.startFollowing('https://bit.ly/2X7gCIT').then(urls => {
    console.log(urls);
}).catch(error => {
    console.log(error)
})

back to top


Output

CLI Result:

https://bit.ly/2X7gCIT -> 301
http://github.com/sthnaqvi/follow-redirect-url -> 301
https://github.com/sthnaqvi/follow-redirect-url -> 200

Project Result:

[ { url: 'https://bit.ly/2X7gCIT',
    redirect: true,
    status: 301,
    redirectUrl: 'http://github.com/sthnaqvi/follow-redirect-url' },
  { url: 'http://github.com/sthnaqvi/follow-redirect-url',
    redirect: true,
    status: 301,
    redirectUrl: 'https://github.com/sthnaqvi/follow-redirect-url' },
  { url: 'https://github.com/sthnaqvi/follow-redirect-url',
    redirect: false,
    status: 200 } ]

back to top


Options

CLI options:

Under development

Module options:

The second argument is an options object. Options are optional.

  • max_redirect_length - maximum redirection limit. Default: 20
  • request_timeout - request timeout in milliseconds. Default: 10000
  • ignoreSslErrors - ignore SSL certificate errors when following redirects. Default: false
const followRedirect = require('follow-redirect-url');

const options = {
    max_redirect_length: 5,
    request_timeout: 5000,
    ignoreSsslErrors: true
};

followRedirect.startFollowing('https://bit.ly/2X7gCIT', options).then(urls => {
    console.log(urls);
}).catch(error => {
    console.log(error)
})

back to top