0.1.0 • Published 6 years ago

url-checker v0.1.0

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

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:

KeyDescription
useGoogleSafeBrowsingboolean indicating whether to use Google Safe Browsing. Default: true
googleSafeBrowsingAPIKeyAPI key to use. Compulsory if useSafeBrowsing is true.
useContentTypeboolean indicating whether to use content-type whitelisting. Default: true
TODO: contentTypeWhitelistAn array of strings indicating content-types to whitelist, e.g. ['text/html', 'text/plain']. Default: ['text/html']