npm.io
0.1.0 • Published 8 years ago

url-checker

Licence
ISC
Version
0.1.0
Deps
2
Size
12 kB
Vulns
1
Weekly
0

url-checker

Simple checks on URLs, for 'safety' or 'maliciousness'. Types of checking:

  1. Google Safe Browsing - uses Google Safe Browsing Lookup API
  2. Content-type whitelisting - uses HTTP HEAD to check Content-Type header of destination resource against a whitelist of accepted content-types

Usage

const UrlChecker = require('url-checker');
...
const uc = new UrlChecker({
    // options
});
uc.check('http://some-url-t0-check.org/blah/')
    .then(results => {
        // do stuff with results
    });

The check() method returns a promise that resolves to an array. The array can contain strings indicating issues resulting from the checks made; if there are no issues found, the array is empty.

Options

The options passed in to the UrlChecker constructor:

Key Description
useGoogleSafeBrowsing boolean indicating whether to use Google Safe Browsing. Default: true
googleSafeBrowsingAPIKey API key to use. Compulsory if useSafeBrowsing is true.
useContentType boolean indicating whether to use content-type whitelisting. Default: true
TODO: contentTypeWhitelist An array of strings indicating content-types to whitelist, e.g. ['text/html', 'text/plain']. Default: ['text/html']