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

insafe

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

insafe

Insafe is a Node.js package which resolves and checks that an URL is well-formed.

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65
increased by441.67%
Maintainers
6
Weekly downloads
 
Created
Source

License Coverage Status

Insafe logo

Insafe is a Node.js package which resolves and checks that an URL is well-formed.

Features

  • URL resolution: w3.org -> http://w3.org
  • DNS check
  • HTTP/HTTPS check (customizable)
  • Host blacklist
  • Host whitelist

Installation

npm install insafe

Usage

Insafe is a JavaScript Promise-based API.

It exposes a check(options) function that returns a Promise. This Promise will resolve to an object containing:

  • resolved url String
  • status (true if well formed, else false) Boolean
  • error report Array

or rejects with the unexpected errors the checker encountered when checking the URL

Example:

var insafe = require('insafe');

insafe.check({
	url: 'example.com'
}).then(function (res) {
  if(res.status == false) {
  console.log('not valid url: ' +res.url);
  } else {
  console.log('The URL is valid.');
  }
}).catch(console.log);

Several options are available to check the URL:

  • url (required): a String.
  • statusCodesAccepted: an Array of accepted HTTP(S) status codes. See the default config.
  • statusCodesRefused: an Array of refused HTTP(S) status codes. See the default config.
  • blacklist: an Array of blacklisted hosts.
  • whitelist: an Array of whitelisted hosts.

Example:

var insafe = require('insafe');

insafe.check({
    url: 'http://www.w3.org/',
    statusCodesAccepted: ["404"],
    statusCodesRefused: ["301", "203"],
    blacklist: ['h4ck3rz.org'],
    whitelist: ['www.w3.org', 'example.com']
}).then(function (res) {
  if(res.status == false) {
  console.log('not valid url: ' +res.url);
  } else {
  console.log('The URL is valid.');
  }
}).catch(console.log);

FAQs

Package last updated on 26 Apr 2023

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