Fix URL building for default repo branch API #1
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "lucidiot/tildepages:fix-default-branch-url"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
I found a bug when trying to use a repo on an organization at https://tildegit.org/casa/pages where the site could be accessed via https://casa.tildepages.org/@main/ but not https://casa.tildepages.org/. Using a
pages
branch or any other name did not do anything.It turns out the issue comes from this bit.
Using the base URL (
giteaRoot
) in path.Join caused it to remove the two slashes (because /////tmp == /tmp):https:/tildegit.org/api/v1/repos/owner/name
Then, using that in URL.Parse causes it to see a
https:
scheme, and the / right afterwards means "start a path here", not a hostname, because hostnames begin with two slashes. That's a valid URL, with no hostname. Then it gets turned back into a string:https:///tildegit.org/api/v1/repos/owner/name
That's another way of expressing the same URL with no hostname:
<scheme>://<empty hostname>/<path>
.curl, Firefox and Chromium all fix the triple slash automatically, but fasthttp doesn't, and it tries to look up the empty string as a DNS host!
⚠️ Note that I am making this PR without testing it locally or anything because I'm at work and just wanted to show a probable fix :p