Skip to content

Commit

Permalink
Ignore <link rel="schema.*" URIs
Browse files Browse the repository at this point in the history
Fixes #190
  • Loading branch information
wjdp committed May 28, 2022
1 parent 1af9b3e commit ce9b128
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions htmltest/check-link.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func (hT *HTMLTest) checkLink(document *htmldoc.Document, node *html.Node) {
return
}

// Ignore rel=schema.*, as URIs from schema links do not have to exist
// Fixes #190
if strings.HasPrefix(attrs["rel"], "schema.") {
return
}

// Create reference
ref, err := htmldoc.NewReference(document, node, attrs["href"])
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions htmltest/check-link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,13 @@ func TestLinkRelDnsPrefetch(t *testing.T) {
tExpectIssueCount(t, hT, 0)
}

func TestLinkRelSchema(t *testing.T) {
// ignores links with rel="schema.*"
// Fixes #190
hT := tTestFile("fixtures/links/link-rel-schema.html")
tExpectIssueCount(t, hT, 0)
}

func TestAnchorPre(t *testing.T) {
// catches broken links when inside pre or code tags
hT := tTestFileOpts("fixtures/links/anchors_in_pre.html",
Expand Down
2 changes: 2 additions & 0 deletions htmltest/fixtures/links/link-rel-schema.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link rel="schema.PA" href="http://www.pictureaustralia.org/schemas/pa/" />
<link rel="schema.dcterms" href="http://purl.org/dc/terms/">

0 comments on commit ce9b128

Please sign in to comment.