Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/pkgsite: shortcut redirect fails if a trailing slash is added #40166

Closed
akolar opened this issue Jul 11, 2020 · 3 comments
Closed

x/pkgsite: shortcut redirect fails if a trailing slash is added #40166

akolar opened this issue Jul 11, 2020 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Milestone

Comments

@akolar
Copy link

akolar commented Jul 11, 2020

pkg.go.dev supports shortcuts for packages from the standard library (for example, https://pkg.go.dev/http redirects to https://pkg.go.dev/net/http). However, these don't work if a trailing / is appended to the URL.

Opening https://pkg.go.dev/http/ results in a redirect to https://pkg.go.dev/http/net/http (and not https://pkg.go.dev/net/http).

Below are the request and the server's response (shortened):

> GET /http/ HTTP/2
> Host: pkg.go.dev
> user-agent: curl/7.71.0
> accept: */*
> 
< HTTP/2 302 
[...]
< location: /http/net/http

In the case of https://github.com/golang/pkgsite/blob/master/internal/frontend/details.go#L432, the url parameter to http.Redirect() is a relative path. Therefore, the (full) redirect path is constructed by appending the relative URL to the current location (https://golang.org/src/net/http/server.go#L2082).

I have a CL ready but it is based on a fix for #39663.

Related: #39663.

@gopherbot gopherbot added this to the Unreleased milestone Jul 11, 2020
@gopherbot
Copy link

Change https://golang.org/cl/242138 mentions this issue: internal/frontend: fix redirects for shortcuts with trailing slashes

@andybons
Copy link
Member

@julieqiu

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2020
@julieqiu julieqiu added pkgsite NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 14, 2020
@julieqiu
Copy link
Member

Thanks @akolar! #39663 has been fixed. Feel free to rebase, and I'll review https://golang.org/cl/242138.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Projects
None yet
Development

No branches or pull requests

4 participants