Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexo-broken-links-checker

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-broken-links-checker - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

1

index.js
hexo.config.broken_links_checker = Object.assign(
{
enable: true,
head: true,
frontmatter: [],

@@ -5,0 +6,0 @@ exclude: [],

31

lib/checkLink.js
const fetch = require('node-fetch');
const checkLink = async (url, timeout) => {
return new Promise((resolve, reject) => {
fetch(url, { timeout: timeout || 0 })
.then(({ status, ok }) => {
if (ok) {
resolve(status);
const runQuery = (url, method, timeout, resolve, reject) => {
fetch(url, { method, timeout })
.then(({ status, ok }) => {
if (ok) {
resolve(status);
} else {
if (method === 'HEAD') {
runQuery(url, 'GET', timeout, resolve, reject);
} else {
reject(status);
}
})
.catch((err) => reject(err));
});
}
})
.catch((err) => {
if (method === 'HEAD') {
runQuery(url, 'GET', timeout, resolve, reject);
} else {
reject(err);
}
});
};
const checkLink = async (url, head, timeout) =>
new Promise((resolve, reject) => {
runQuery(url, head ? 'HEAD' : 'GET', timeout || 0, resolve, reject);
});
module.exports = { checkLink };

@@ -14,3 +14,3 @@ const { magenta, blue, red } = require('chalk');

if (config.broken_links_checker) {
const { enable, exclude, frontmatter, timeout } = config.broken_links_checker;
const { enable, head, exclude, frontmatter, timeout } = config.broken_links_checker;

@@ -70,3 +70,3 @@ if (enable) {

log.info('Checking URL: %s', magenta(url));
await checkLink(url, timeout);
await checkLink(url, head, timeout);
} else {

@@ -87,2 +87,4 @@ log.info('URL check skip: %s', magenta(url));

throw new Error(`${brokenLinks.length} external link(s) are broken.`);
} else {
log.info('URL check is done. All links are alive.');
}

@@ -89,0 +91,0 @@ });

{
"name": "hexo-broken-links-checker",
"version": "1.0.2",
"version": "1.1.0",
"description": "Broken links checker for Hexo static site generator",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc