New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parse-refresh-redirect

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-refresh-redirect

Parse HTML and return a redirect URL if one is defined in the content attribute of a meta[http-equiv="refresh"] element.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

parse-refresh-redirect

Package Version

Parse HTML with parse5 and return a redirect URL if one is defined in the content attribute of a <meta http-equiv="refresh"/> element.

Features

  • API and CLI
  • 100% unit test coverage
  • TypeScript module definition

Installation

npm install parse-refresh-redirect

or

yarn add parse-refresh-redirect

Usage

API

const parseURL = require('parse-refresh-redirect');
parseURL(html)

Parse HTML string and return redirect URL string or undefined.

Examples
const html = `
  <html>
    <head>
      <meta http-equiv="refresh" content="0; url=https://example.com/foo.html" />
    </head>
  </html>
`;

const url = parseURL(html);

// url === 'https://example.com/foo.html'
const html = `
  <html>
    <head>
      <meta http-equiv="refresh" content="5" />
    </head>
  </html>
`;

const url = parseURL(html);

// url === undefined
const html = `
  <html>
    <head>
      <title>Test</test>
    </head>
  </html>
`;

const url = parseURL(html);

// url === undefined

CLI

The CLI will parse HTML input from stdin and output the redirect URL if found (it will output nothing if no URL was found).

# HTML from local file
cat index.html | parse-refresh-redirect

# HTML from URL
curl -s "https://adamjarret.github.io" | parse-refresh-redirect

If parse-refresh-redirect is not installed globally, run it with npx (ex. cat index.html | npx parse-refresh-redirect).

The exit code will be 0 if the URL was found, otherwise 1.

The CLI takes no options.

Author

Adam Jarret

Keywords

FAQs

Package last updated on 04 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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