]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
Show alternative link only if it differs
authorSergey Matveev <stargrave@stargrave.org>
Sat, 20 Apr 2024 17:00:18 +0000 (20:00 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 20 Apr 2024 17:00:24 +0000 (20:00 +0300)
rounds/gemini.go

index b3d942926f16e3a3c0e71fe615f350c94cafa1f4..71da97f361bfe33526a696be30e00ac0b2177b62 100644 (file)
@@ -227,14 +227,22 @@ func RoundGemini(
                                switch len(cols) {
                                case 1:
                                        fmt.Fprintf(
-                                               &buf, "<a href=\"%s\">%s</a>&nbsp;<a href=\"%s\">[2]</a><br/>\n",
-                                               u1, html.EscapeString(cols[0]), u2,
+                                               &buf, "<a href=\"%s\">%s</a>",
+                                               u1, html.EscapeString(cols[0]),
                                        )
+                                       if u1 != u2 {
+                                               fmt.Fprintf(&buf, "&nbsp;<a href=\"%s\">[2]</a>", u2)
+                                       }
+                                       fmt.Fprintf(&buf, "<br/>\n")
                                default:
                                        fmt.Fprintf(
-                                               &buf, "<a href=\"%s\">%s</a>&nbsp;<a href=\"%s\">[2]</a>(<tt>%s</tt>)<br/>\n",
-                                               u1, html.EscapeString(strings.Join(cols[1:], " ")), u2, cols[0],
+                                               &buf, "<a href=\"%s\">%s</a>",
+                                               u1, html.EscapeString(strings.Join(cols[1:], " ")),
                                        )
+                                       if u1 != u2 {
+                                               fmt.Fprintf(&buf, "&nbsp;<a href=\"%s\">[2]</a>", u2)
+                                       }
+                                       fmt.Fprintf(&buf, "(<tt>%s</tt>)<br/>\n", cols[0])
                                }
                                continue
                        }