Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bin/lint-markdown-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const diagnosticOptions: DiagnosticOptions = {
};

async function fetchExternalLink(link: string, checkRedirects = false) {
const url = new URL(link);
if (url.hostname.endsWith('.npmjs.com')) {
console.log('Skipping npmjs.com link check', link);
return true;
}

try {
const response = await fetch(link, {
headers: {
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/skipped-external-link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a skipped [external link](https://www.npmjs.com/support)
12 changes: 12 additions & 0 deletions tests/lint-roller-markdown-links.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ describe('lint-roller-markdown-links', () => {
expect(status).toEqual(0);
});

it('should skip npmjs.com links', () => {
const { status, stdout } = runLintMarkdownLinks(
'--root',
FIXTURES_DIR,
'skipped-external-link.md',
'--fetch-external-links',
);

expect(status).toEqual(0);
expect(stdout).toContain('Skipping');
});

it('should disallow absolute links by default', () => {
const { status, stdout } = runLintMarkdownLinks(
'--root',
Expand Down