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

linkinator

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkinator - npm Package Compare versions

Comparing version 1.7.5 to 1.8.0

2

build/src/index.d.ts

@@ -8,3 +8,3 @@ /// <reference types="node" />

recurse?: boolean;
linksToSkip?: string[];
linksToSkip?: string[] | ((link: string) => Promise<boolean>);
}

@@ -11,0 +11,0 @@ export declare enum LinkState {

@@ -101,9 +101,5 @@ "use strict";

}
// Check for user configured links that should be skipped
const skips = opts.checkOptions
.linksToSkip.map(linkToSkip => {
return new RegExp(linkToSkip).test(opts.url.href);
})
.filter(match => !!match);
if (skips.length > 0) {
// Check for a user-configured function to filter out links
if (typeof opts.checkOptions.linksToSkip === 'function' &&
(await opts.checkOptions.linksToSkip(opts.url.href))) {
const result = {

@@ -118,2 +114,20 @@ url: opts.url.href,

}
// Check for a user-configured array of link regular expressions that should be skipped
if (Array.isArray(opts.checkOptions.linksToSkip)) {
const skips = opts.checkOptions.linksToSkip
.map(linkToSkip => {
return new RegExp(linkToSkip).test(opts.url.href);
})
.filter(match => !!match);
if (skips.length > 0) {
const result = {
url: opts.url.href,
state: LinkState.SKIPPED,
parent: opts.parent,
};
opts.results.push(result);
this.emit('link', result);
return;
}
}
// Perform a HEAD or GET request based on the need to crawl

@@ -120,0 +134,0 @@ let status = 0;

{
"name": "linkinator",
"description": "Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.",
"version": "1.7.5",
"version": "1.8.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "JustinBeckwith/linkinator",

@@ -130,3 +130,3 @@ # 🐿 linkinator

- `recurse` (boolean) - By default, all scans are shallow. Only the top level links on the requested page will be scanned. By setting `recurse` to `true`, the crawler will follow all links on the page, and continue scanning links **on the same domain** for as long as it can go. Results are cached, so no worries about loops.
- `linksToSkip` (array) - An array of regular expression strings that should be skipped during the scan.
- `linksToSkip` (array | function) - An array of regular expression strings that should be skipped, OR an async function that's called for each link with the link URL as its only argument. Return a Promise that resolves to `true` to skip the link or `false` to check it.

@@ -204,2 +204,5 @@ #### linkinator.LinkChecker()

console.log(` ${result.status}`);
// What page linked here?
console.log(` ${result.parent}`);
});

@@ -206,0 +209,0 @@

Sorry, the diff of this file is not supported yet

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