* * * * *

                          It was a simple bug, but …

I was right about the double slash bug [1]—it was a simple bug after all [2].
The authors of two Gemini crawlers wrote in about the double slash bug, and
from them, I was able to get the root cause of the problem—my blog on Gemini
[3]. Good thing I hedged my statement about not being the cause yesterday.
Sigh.

Back in Debtember, I added support for displaying multiple posts [4]. It's
not an easy feature to describe, but basically, it allows one to (by hacking
the URL (Uniform Resource Locator), but who hacks URLs these days?) specify
posts via a range of dates. And it's on these pages that the double slashed
URLs appear. Why that happens is easy—I was generating the links directly
from strings:

-----[ Lua ]-----
local function geminilink(entry)
 return string.format("gemini://%s%s/%s%04d/%02d/%02d.%d",
           config.url.host,
           port, -- generated elsewhere
           config.url.path,
           entry.when.year,
           entry.when.month,
           entry.when.day,
           entry.when.part
   )
end
-----[ END OF LINE ]-----

instead of from a URL type. I think when I wrote the above code, I wasn't
thinking in terms of a URL type, but of constructing a URL from data I
already had. The bug itself is due to config.url.path ending in a slash, so
the third slash in the string literal wasn't needed. The correct way isn't
that hard:

-----[ Lua ]-----
local function geminilink(entry)
 return uurl.toa(uurl.merge(config.url,
               {
                 path = string.format("%04d/%02d/%02d.%d",
                               entry.when.year,
                               entry.when.month,
                               entry.when.day,
                               entry.when.part)
               }))
end
-----[ END OF LINE ]-----

and it wouldn't have exhibited the issue.

With this fix in place, I think I will continue to reject requests with the
double slash, as it is catching bugs, which is a Good Thing™.

[1] gopher://gopher.conman.org/0Phlog:2022/04/30.1
[2] gopher://gopher.conman.org/0Phlog:2022/04/16.1
[3] gemini://gemini.conman.org/boston/
[4] gopher://gopher.conman.org/0Phlog:2021/12/06.2

Email author at [email protected]