From 3a00064036f01776ec85e205247c31d67cd1123e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 18 Apr 2024 10:19:26 +0300 Subject: [PATCH] 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. --- rounds/gemini.go | 11 ++++++----- version.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) 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" -- 2.44.0