linkinator
Advanced tools
Comparing version 1.7.4 to 1.7.5
@@ -40,8 +40,32 @@ "use strict"; | ||
}); | ||
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, baseUrl)); | ||
.map(link => parseLink(link, realBaseUrl)); | ||
return sanitized; | ||
} | ||
exports.getLinks = getLinks; | ||
function getBaseUrl(htmlBaseUrl, oldBaseUrl) { | ||
if (isAbsoluteUrl(htmlBaseUrl)) { | ||
return htmlBaseUrl; | ||
} | ||
const url = new url_1.URL(htmlBaseUrl, oldBaseUrl); | ||
url.hash = ''; | ||
return url.href; | ||
} | ||
function isAbsoluteUrl(url) { | ||
// Don't match Windows paths | ||
if (/^[a-zA-Z]:\\/.test(url)) { | ||
return false; | ||
} | ||
// Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 | ||
// Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 | ||
return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url); | ||
} | ||
function parseAttr(name, value) { | ||
@@ -48,0 +72,0 @@ switch (name) { |
{ | ||
"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.4", | ||
"version": "1.7.5", | ||
"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
45145
588