Skip to content

Function to return summary details of last URL redirect in a chain

License

Notifications You must be signed in to change notification settings

nullish/last-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

last-redirect

A shortcut function to return summary details of last URL redirect in a chain.

For use with the Puppeteer Node library for Chromium web browser automation.

Usage

Incorporate the function into a Puppeteer script. E.g.

const puppeteer = require('puppeteer');
const lastRedirect = require('last-redirect');

(async () => {
  const browser = await puppeteer.launch({});
  const page = await browser.newPage()
  const res = await page.goto('http://www.google.com', { waitUntil: 'networkidle2' })
  console.log(lastRedirect(res));
  await browser.close()
})()

Expected result

{ count: 1, status: 302, statusText: 'Found' }

About

Function to return summary details of last URL redirect in a chain

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published