Skip to content

Commit

Permalink
chore(build): update some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed May 19, 2023
1 parent 037ac80 commit ae818db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/flaws/broken-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function getBrokenLinksFlaws(
const absoluteURL = new URL(href, "http://www.example.com");
const found = Document.findByURL(hrefNormalized);
if (!found) {
// Before we give up, check if it's an image.
// Before we give up, check if it's an attachment.
if (!FileAttachment.findByURLWithFallback(hrefNormalized)) {
// Even if it's a redirect, it's still a flaw, but it'll be nice to
// know what it *should* be.
Expand Down
12 changes: 6 additions & 6 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,21 @@ export function postLocalFileLinks($, doc) {
const href = element.attribs.href;

// This test is merely here to quickly bail if there's no hope to find the
// image as a local file link. There are a LOT of hyperlinks throughout
// the content and this simple if statement means we can skip 99% of the
// links, so it's presumed to be worth it.
// file attachment as a local file link. There are a LOT of hyperlinks
// throughout the content and this simple if statement means we can skip 99%
// of the links, so it's presumed to be worth it.
if (
!href ||
/^(\/|\.\.|http|#|mailto:|about:|ftp:|news:|irc:|ftp:)/i.test(href)
) {
return;
}
// There are a lot of links that don't match. E.g. `<a href="SubPage">`
// So we'll look-up a lot "false positives" that are not images.
// So we'll look-up a lot "false positives" that are not file attachments.
// Thankfully, this lookup is fast.
const url = `${doc.mdn_url}/${href}`;
const image = FileAttachment.findByURLWithFallback(url);
if (image) {
const fileAttachment = FileAttachment.findByURLWithFallback(url);
if (fileAttachment) {
$(element).attr("href", url);
}
});
Expand Down

0 comments on commit ae818db

Please sign in to comment.