w3c/insafe

Name: insafe

Owner: World Wide Web Consortium

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

Created: 2014-09-08 14:15:55.0

Updated: 2017-09-28 10:31:45.0

Pushed: 2017-11-30 10:51:34.0

Homepage:

Size: 107

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

npm version License Build Status Coverage Status Dependency Status devDependency Status

Insafe logo

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

Features
Installation
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:

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

Example:

insafe = require('insafe');

fe.check({
url: 'example.com'
hen(function (res) {
(res.status == false) {
nsole.log('not valid url: ' +res.url);
else {
nsole.log('The URL is valid.');

atch(console.log);

Several options are available to check the URL:

Example:

insafe = require('insafe');

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

atch(console.log);

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.