linkinator
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -200,13 +200,17 @@ "use strict"; | ||
} | ||
opts.queue.add(async () => { | ||
await this.crawl({ | ||
url: result.url, | ||
crawl, | ||
cache: opts.cache, | ||
results: opts.results, | ||
checkOptions: opts.checkOptions, | ||
queue: opts.queue, | ||
parent: opts.url.href, | ||
// Ensure the url hasn't already been touched, largely to avoid a | ||
// very large queue length and runaway memory consumption | ||
if (!opts.cache.has(result.url.href)) { | ||
opts.queue.add(async () => { | ||
await this.crawl({ | ||
url: result.url, | ||
crawl, | ||
cache: opts.cache, | ||
results: opts.results, | ||
checkOptions: opts.checkOptions, | ||
queue: opts.queue, | ||
parent: opts.url.href, | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -213,0 +217,0 @@ } |
@@ -32,4 +32,12 @@ "use strict"; | ||
const $ = cheerio.load(source); | ||
let realBaseUrl = baseUrl; | ||
const base = $('base[href]'); | ||
if (base.length) { | ||
// only first <base by specification | ||
const htmlBaseUrl = base.first().attr('href'); | ||
realBaseUrl = getBaseUrl(htmlBaseUrl, baseUrl); | ||
} | ||
const links = new Array(); | ||
Object.keys(linksAttr).forEach(attr => { | ||
const attrs = Object.keys(linksAttr); | ||
for (const attr of attrs) { | ||
const elements = linksAttr[attr].map(tag => `${tag}[${attr}]`).join(','); | ||
@@ -44,16 +52,11 @@ $(elements).each((i, element) => { | ||
} | ||
links.push(...values); | ||
for (const v of values) { | ||
if (!!v) { | ||
const link = parseLink(v, realBaseUrl); | ||
links.push(link); | ||
} | ||
} | ||
}); | ||
}); | ||
let realBaseUrl = baseUrl; | ||
const base = $('base[href]'); | ||
if (base.length) { | ||
// only first <base by specification | ||
const htmlBaseUrl = base.first().attr('href'); | ||
realBaseUrl = getBaseUrl(htmlBaseUrl, baseUrl); | ||
} | ||
const sanitized = links | ||
.filter(link => !!link) | ||
.map(link => parseLink(link, realBaseUrl)); | ||
return sanitized; | ||
return links; | ||
} | ||
@@ -60,0 +63,0 @@ exports.getLinks = getLinks; |
{ | ||
"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.1", | ||
"version": "2.0.2", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "repository": "JustinBeckwith/linkinator", | ||
"@types/sinon": "^7.5.0", | ||
"@types/update-notifier": "^2.5.0", | ||
"@types/update-notifier": "^4.0.0", | ||
"assert-rejects": "^1.0.0", | ||
@@ -52,6 +52,5 @@ "c8": "^7.0.0", | ||
"mocha": "^7.0.0", | ||
"nock": "^11.4.0", | ||
"nock": "^12.0.0", | ||
"semantic-release": "^17.0.0", | ||
"sinon": "^8.0.0", | ||
"source-map-support": "^0.5.13", | ||
"sinon": "^9.0.0", | ||
"typescript": "^3.6.4" | ||
@@ -81,9 +80,3 @@ }, | ||
] | ||
}, | ||
"mocha": { | ||
"check-leaks": true, | ||
"timeout": 10000, | ||
"throw-deprecation": true, | ||
"require": "source-map-support/register" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
47457
21
616