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
Size: 107
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Insafe is a Node.js package which resolves and checks that an URL is well-formed.
w3.org
-> http://w3.org
install insafe
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:
String
Boolean
Array
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:
String
.Array
of accepted HTTP(S) status codes. See the default config.Array
of refused HTTP(S) status codes. See the default config.Array
of blacklisted hosts.Array
of whitelisted hosts.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);