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
Milestone

Comments

@akolar
Copy link

@akolar 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

@gopherbot gopherbot commented Jul 11, 2020

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

@andybons
Copy link
Member

@andybons andybons commented Jul 13, 2020

@julieqiu
Copy link
Contributor

@julieqiu julieqiu commented Jul 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants