linkinator
Advanced tools
Comparing version 2.0.2 to 2.0.3
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import PQueue, { DefaultAddOptions } from 'p-queue'; | ||
import { URL } from 'url'; | ||
import PriorityQueue from 'p-queue/dist/priority-queue'; | ||
export interface CheckOptions { | ||
@@ -25,2 +28,11 @@ concurrency?: number; | ||
} | ||
interface CrawlOptions { | ||
url: URL; | ||
parent?: string; | ||
crawl: boolean; | ||
results: LinkResult[]; | ||
cache: Set<string>; | ||
checkOptions: CheckOptions; | ||
queue: PQueue<PriorityQueue, DefaultAddOptions>; | ||
} | ||
/** | ||
@@ -53,3 +65,3 @@ * Instance class used to perform a crawl job. | ||
*/ | ||
private crawl; | ||
crawl(opts: CrawlOptions): Promise<void>; | ||
} | ||
@@ -64,1 +76,2 @@ /** | ||
}>; | ||
export {}; |
@@ -40,2 +40,5 @@ "use strict"; | ||
const results = new Array(); | ||
const url = new url_1.URL(options.path); | ||
const initCache = new Set(); | ||
initCache.add(url.href); | ||
queue.add(async () => { | ||
@@ -47,3 +50,3 @@ await this.crawl({ | ||
results, | ||
cache: new Set(), | ||
cache: initCache, | ||
queue, | ||
@@ -85,7 +88,2 @@ }); | ||
async crawl(opts) { | ||
// Check to see if we've already scanned this url | ||
if (opts.cache.has(opts.url.href)) { | ||
return; | ||
} | ||
opts.cache.add(opts.url.href); | ||
// explicitly skip non-http[s] links before making the request | ||
@@ -206,2 +204,3 @@ const proto = opts.url.protocol; | ||
if (!opts.cache.has(result.url.href)) { | ||
opts.cache.add(result.url.href); | ||
opts.queue.add(async () => { | ||
@@ -208,0 +207,0 @@ await this.crawl({ |
{ | ||
"name": "linkinator", | ||
"description": "Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "JustinBeckwith/linkinator", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47891
628