]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
gemini's links can be without whitespace after =>
authorSergey Matveev <stargrave@stargrave.org>
Thu, 10 Aug 2023 14:13:01 +0000 (17:13 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 10 Aug 2023 14:13:10 +0000 (17:13 +0300)
rounds/gemini.go

index d81039fd01872a9aabd2627658de1b8fb68a2848..219fdcb2f61f108d303002a32ad7a8913fa4c80a 100644 (file)
@@ -221,19 +221,20 @@ func RoundGemini(
                                fmt.Fprintf(&buf, "%s\n", line)
                                continue
                        }
-                       if strings.HasPrefix(line, "=> ") {
+                       if strings.HasPrefix(line, "=>") {
+                               line = strings.TrimLeft(line[2:], " ")
                                cols = strings.Fields(line)
-                               u := geminifyURL(host, cols[1], paths...)
+                               u := geminifyURL(host, cols[0], paths...)
                                switch len(cols) {
-                               case 2:
+                               case 1:
                                        fmt.Fprintf(
                                                &buf, "<a href=\"%s\">%s</a><br/>\n",
-                                               u, html.EscapeString(cols[1]),
+                                               u, html.EscapeString(cols[0]),
                                        )
                                default:
                                        fmt.Fprintf(
                                                &buf, "<a href=\"%s\">%s</a> (<tt>%s</tt>)<br/>\n",
-                                               u, html.EscapeString(strings.Join(cols[2:], " ")), cols[1],
+                                               u, html.EscapeString(strings.Join(cols[1:], " ")), cols[0],
                                        )
                                }
                                continue