1.0.2 • Published 4 years ago
urls-validator v1.0.2
URLs / Images Validator
Fetch all page urls - including images, then validate they're working or not.
Getting started
npm install urls-validator
Usage for Links
const { urlsValidator } = require('../index');
urlsValidator('https://example.com') // http / https is important
.then(res => {
console.log(res);
})
.catch(err => console.log(err));
The result is an object of ok, fail and error urls
{
ok: ['list-of-working-urls'], // status code: 200
fail: [['url', 'status-code'], [...]], // status code will not be 200
error: [['url', 'message'], [...]], // Could be certificate / authenticate error
}
Usage for Images
This method may not get all of the images because of the asynchronous loading.
const { imagesValidator } = require('../index');
imagesValidator('https://example.com') // http / https is important
.then(res => {
console.log(res);
})
.catch(err => console.log(err));
The result is an object of ok, fail and error urls
{
ok: ['list-of-working-urls'], // status code: 200
fail: [['url', 'status-code'], [...]], // status code will not be 200
error: [['url', 'message'], [...]], // Could be certificate / authenticate error
}
Urls Validator for the whole website
We could get all pages from sitemap.xml, then loops through all the links. You should have a sitemap.xml on your website for SEO purposes.
Contributions
This project is based on urls-validator, feel free to report bugs and make feature requests in the Issue Tracker, fork and create pull requests!
1.0.2
4 years ago