From: Sergey Matveev Date: Thu, 18 Apr 2024 07:19:26 +0000 (+0300) Subject: Alternative Gemini's relative URL forming X-Git-Tag: v0.5.0~3 X-Git-Url: http://www.git.stargrave.org/?p=tofuproxy.git;a=commitdiff_plain;h=3a00064036f01776ec85e205247c31d67cd1123e Alternative Gemini's relative URL forming 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. --- diff --git a/rounds/gemini.go b/rounds/gemini.go index 987b62e..b3d9429 100644 --- a/rounds/gemini.go +++ b/rounds/gemini.go @@ -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, "%s
\n", - u, html.EscapeString(cols[0]), + &buf, "%s [2]
\n", + u1, html.EscapeString(cols[0]), u2, ) default: fmt.Fprintf( - &buf, "%s (%s)
\n", - u, html.EscapeString(strings.Join(cols[1:], " ")), cols[0], + &buf, "%s [2](%s)
\n", + u1, html.EscapeString(strings.Join(cols[1:], " ")), u2, cols[0], ) } continue diff --git a/version.go b/version.go index 732fa04..14ab79e 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package tofuproxy -const Version = "0.4.0" +const Version = "0.5.0"