Skip to content

Improve <meta> tag content URL validation #35

@lkmgr

Description

@lkmgr

The content attribute of a <meta> tag is assumed to be a URL if new URL(content) doesn't throw an error:

linkinator/src/links.ts

Lines 121 to 129 in 39ca01c

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

However, this may be too lenient as it leads to values that are not meant to be URLs to be treated as URLs, like the following:

<meta name="description" content="Test: Hello">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions