]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
Alternative Gemini's relative URL forming
authorSergey Matveev <stargrave@stargrave.org>
Thu, 18 Apr 2024 07:19:26 +0000 (10:19 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 18 Apr 2024 10:25:58 +0000 (13:25 +0300)
Specification clearly states:
    URL may be absolute or relative. If relative, it should be resolved
    against the URL used in the original request.
So "gemini://foo.bar/baz" with "doo" relative URL must give
"gemini://foo.bar/baz/doo" URL. But initial Gemini's Python demo
(https://tildegit.org/solderpunk/gemini-demo-1.git) performs urljoin
call, that will give "gemini://foo.bar/doo". Seems that many gemsites
expect that behaviour from the client.

rounds/gemini.go
version.go

index 987b62eb7115c8e9879a910ccd44163135a43ff6..b3d942926f16e3a3c0e71fe615f350c94cafa1f4 100644 (file)
@@ -222,17 +222,18 @@ func RoundGemini(
                        if strings.HasPrefix(line, "=>") {
                                line = strings.TrimLeft(line[2:], " ")
                                cols = strings.Fields(line)
-                               u := geminifyURL(host, cols[0], paths...)
+                               u1 := geminifyURL(host, cols[0], paths...)
+                               u2 := geminifyURL(host, cols[0])
                                switch len(cols) {
                                case 1:
                                        fmt.Fprintf(
-                                               &buf, "<a href=\"%s\">%s</a><br/>\n",
-                                               u, html.EscapeString(cols[0]),
+                                               &buf, "<a href=\"%s\">%s</a>&nbsp;<a href=\"%s\">[2]</a><br/>\n",
+                                               u1, html.EscapeString(cols[0]), u2,
                                        )
                                default:
                                        fmt.Fprintf(
-                                               &buf, "<a href=\"%s\">%s</a> (<tt>%s</tt>)<br/>\n",
-                                               u, html.EscapeString(strings.Join(cols[1:], " ")), cols[0],
+                                               &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],
                                        )
                                }
                                continue
index 732fa0428e946848d530823f74e6b3b1d1af5c72..14ab79e00b050aa87055d6b0730fcca6f88d8e94 100644 (file)
@@ -1,3 +1,3 @@
 package tofuproxy
 
-const Version = "0.4.0"
+const Version = "0.5.0"