Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JustinBeckwith/linkinator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.10.1
Choose a base ref
...
head repository: JustinBeckwith/linkinator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.11.0
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Dec 24, 2020

  1. Copy the full SHA
    a8c0a43 View commit details
Showing with 31 additions and 0 deletions.
  1. +12 −0 src/links.ts
  2. +11 −0 test/fixtures/twittercard/index.html
  3. +8 −0 test/test.ts
12 changes: 12 additions & 0 deletions src/links.ts
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ const linksAttr = {
icon: ['command'],
longdesc: ['frame', 'iframe'],
manifest: ['html'],
content: ['meta'],
poster: ['video'],
pluginspage: ['embed'],
pluginurl: ['embed'],
@@ -56,6 +57,17 @@ export function getLinks(source: string, baseUrl: string): ParsedUrl[] {
) {
return;
}

// Only for <meta content=""> tags, only validate the url if
// the content actually looks like a url
if (element.tagName === 'meta' && element.attribs['content']) {
try {
new URL(element.attribs['content']);
} catch (e) {
return;
}
}

for (const v of values) {
if (v) {
const link = parseLink(v, realBaseUrl);
11 changes: 11 additions & 0 deletions test/fixtures/twittercard/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
<head>
<meta name="twitter:card" content="summary"></meta>
<meta name="twitter:creator" content="@justinbeckwith" />
<meta name="twitter:site" content="@justinbeckwith" />
<meta property="og:url" content="http://fake.local/" />
<meta property="og:title" content="A Twitter for My Sister" />
<meta property="og:description" content="In the early days, Twitter grew so quickly that it was almost impossible to add new features because engineers spent their time trying to keep the rocket ship from stalling." />
<meta property="og:image" content="http://fake.local" />
</head>
</html>
8 changes: 8 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -445,4 +445,12 @@ describe('linkinator', () => {
const err = results.links[0].failureDetails![0] as Error;
assert.ok(/Nock: Disallowed net connect for/.test(err.message));
});

it('should scan links in <meta content="URL"> tags', async () => {
const scope = nock('http://fake.local').head('/').reply(200);
const results = await check({path: 'test/fixtures/twittercard'});
assert.ok(results.passed);
scope.done();
assert.strictEqual(results.links.length, 2);
});
});