fix: replace stackoverflow.com links with path

This commit is contained in:
httpjamesm
2024-03-09 11:55:02 -05:00
parent 596ffaa02a
commit 5ec826a160
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -35,10 +35,10 @@ func ReplaceStackOverflowLinks(html string) string {
if len(parts) > 2 {
// Prepend the subdomain to the path
url.Path = "/exchange/" + parts[0] + url.Path
newUrl = url.Path + url.RawQuery + url.Fragment
}
newUrl = url.Path + url.RawQuery + url.Fragment
// Replace the href attribute value in the anchor tag
return strings.Replace(match, hrefMatch[1], newUrl, 1)
})
+1 -1
View File
@@ -25,7 +25,7 @@ var sampleInput = `<div class="d-flex fd-column fw-nowrap">
</span>
</div>
<div class="flex--item mb0 mt4">
<a href="/questions/27221504/how-can-you-make-a-safe-static-singleton-in-rust" dir="ltr">How can you make a safe static singleton in Rust?</a>
<a href="https://stackoverflow.com/questions/27221504/how-can-you-make-a-safe-static-singleton-in-rust" dir="ltr">How can you make a safe static singleton in Rust?</a>
<span class="question-originals-answer-count">
(5 answers)
</span>