MCPcopy Index your code
hub / github.com/apache/answer / FormatLinkNofollow

Function FormatLinkNofollow

internal/base/server/http_funcmap.go:140–154  ·  view source on GitHub ↗
(html string)

Source from the content-addressed store, hash-verified

138}
139
140func FormatLinkNofollow(html string) string {
141 var hrefRegexp = regexp.MustCompile("(?m)<a.*?[^<]>.*?</a>")
142 match := hrefRegexp.FindAllString(html, -1)
143 for _, v := range match {
144 hasNofollow := strings.Contains(v, "rel=\"nofollow\"")
145 hasSiteUrl := strings.Contains(v, controller.SiteUrl)
146 if !hasSiteUrl {
147 if !hasNofollow {
148 nofollowUrl := strings.Replace(v, "<a", "<a rel=\"nofollow\"", 1)
149 html = strings.Replace(html, v, nofollowUrl, 1)
150 }
151 }
152 }
153 return html
154}

Callers 1

http_funcmap.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected