url-checker
v0.1.0
Published
Checks URLs for safety, using several methods
Downloads
9
Readme
url-checker
Simple checks on URLs, for 'safety' or 'maliciousness'. Types of checking:
- Google Safe Browsing - uses Google Safe Browsing Lookup API
- 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']
