This commit is contained in:
Kirill Zhuravlev 2023-02-14 19:46:53 +01:00 committed by Avelino
parent bb94bde97e
commit 994209cce9
No known key found for this signature in database
GPG Key ID: B345B4D52E98180A

View File

@ -192,6 +192,8 @@ func changeLinksInIndex(html string, query *goquery.Document, objs map[string]*O
query.Find("body #content ul li ul li a").Each(func(_ int, s *goquery.Selection) {
href, hrefExists := s.Attr("href")
if !hrefExists {
// FIXME: looks like is an error. Tag `a` in our case always
// should have `href` attr.
return
}
@ -201,10 +203,15 @@ func changeLinksInIndex(html string, query *goquery.Document, objs map[string]*O
return
}
// FIXME: parse url
uri := strings.SplitAfter(href, "#")
if len(uri) >= 2 && uri[1] != "contents" {
// FIXME: use s.SetAttr
html = strings.ReplaceAll(
html, fmt.Sprintf(`href="%s"`, href), fmt.Sprintf(`href="%s"`, uri[1]))
html,
fmt.Sprintf(`href="%s"`, href),
fmt.Sprintf(`href="%s"`, uri[1]),
)
}
})