Closed ghost closed 5 years ago
Part of the problem is url.ResolveReference()
. Consider the following code snippets:
const (
base = "https://a.b.c.com/path/"
relative = "raw"
)
func main() {
baseU := url.Parse("https://a.b.c.com/path/")
relU := url.Parse("raw")
link := baseU.ResolveReference(relU)
}
This will cause link
to have the value "https://a.b.c.com/path/raw", as expected. But consider
func main() {
baseU := url.Parse("https://a.b.c.com/path")
relU := url.Parse("raw")
link := baseU.ResolveReference(relU)
}
Now, link
has the value "https://a.b.c.com/raw". This may perhaps also be expected. But now consider
func main() {
baseU := url.Parse("https://a.b.c.com/path")
relU := url.Parse("/raw")
link := baseU.ResolveReference(relU)
}
This doesn't make a difference! Even now, link
contains "https://a.b.c.com/raw". Okay, you may say, let's put slashes everywhere, just to be on the safe side:
func main() {
baseU := url.Parse("https://a.b.c.com/path/")
relU := url.Parse("/raw")
link := baseU.ResolveReference(relU)
}
Nope, link
still contains "https://a.b.c.com/raw". So the only way to get the behaviour we want is:
I'm thinking of making sure that
NewConfigFromJSON()
, BaseURL
terminates in a slash andPTOConfiguration.LinkTo()
, relative
does not begin with one.I implemented the suggestion in the previous comment and now everything seems to work OK
Links in cached queries have "/query/..." but should have baseUrl prepended