Add rel="nofollow" to issue filter links
The issue filter links should not be crawled by search engines, because they they only filter results, and contain nothing new, yet, they put a considerable load on the server. To stop - well behaving - search engines from following these links, add a `rel="nofollow"` property to them. The same property is already present on the archive download links, and plenty of other places. Fixes #2361. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
1e364cc21f
commit
5143ebb507
2 changed files with 46 additions and 28 deletions
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// Copyright 2024 The Forgejo Authors c/o Codeberg e.V.. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package integration
|
||||
|
@ -797,3 +798,20 @@ func TestCommitRefComment(t *testing.T) {
|
|||
assert.Contains(t, event, "referenced this issue")
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssueFilterNoFollow(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
// Check that every link in the filter list has rel="nofollow".
|
||||
filterLinks := htmlDoc.Find(".issue-list-toolbar-right a[href*=\"/issues?q=\"]")
|
||||
assert.True(t, filterLinks.Length() > 0)
|
||||
filterLinks.Each(func(i int, link *goquery.Selection) {
|
||||
rel, has := link.Attr("rel")
|
||||
assert.True(t, has)
|
||||
assert.Equal(t, "nofollow", rel)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue