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

libp2phttp: don't strip / suffix when mounting handler #2552

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Sep 3, 2023

This allows us to serve /a/b when we mount a http.ServeMux handler for /b on a libp2phost at path /a.
Currently this is a 404 as /a/b will reach the handler for /b with the url b as we strip /a/.
The paths on a ServeMux have to begin with / as cleanPath here will add the prefix / and then the comparison here will redirect to the cleaned path. This redirect will cause a 404. See the added test and linked issue for details.

There is an annoying case though,

closes: #2545

@sukunrt sukunrt merged commit 762ad1a into master Oct 10, 2023
11 checks passed
@sukunrt sukunrt deleted the sukun/http-root-2 branch October 10, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

httplibp2p: cannot mount a protocol at the root
3 participants