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

path with an extra initial / #738

Open
maddyblue opened this issue Nov 3, 2020 · 5 comments · May be fixed by #993
Open

path with an extra initial / #738

maddyblue opened this issue Nov 3, 2020 · 5 comments · May be fixed by #993
Labels
bug Something isn't working

Comments

@maddyblue
Copy link

I wrote a client with a small bug where it makes a request to a warp server with an extra / at the front of the path: //api/v1/blah. My reading of the code suggests that it is currently not possible to make a warp filter that can match this because the path function rejects empty parts and parts with slashes. Is there a way to do this?

@maddyblue maddyblue added the bug Something isn't working label Nov 3, 2020
@anmacdonald
Copy link

I've also hit this. I've found an interesting blog on the topic: https://www.ctrl.blog/entry/relative-double-slashes-url.html

Currently, it looks like the only way round this problem is to use a reverse proxy to merge the slashes on warp's behalf.

@jxs
Copy link
Collaborator

jxs commented Jan 7, 2022

Hi! You could try using warp::service to convert the filters to a service and then get the hyper request and alter it's path.
See how warp uses service_fn for an example where you can get the hyper::Request

@anmacdonald
Copy link

Cheers, @jxs! That's a big help. I'll investigate this workaround.

@clickonetwo
Copy link

@jxs Did you get anywhere with this? @seanmonstar Any chance we could get a new filter behavior to canonicalize multiple slashes?

brotskydotcom added a commit to brotskydotcom/warp that referenced this issue Sep 2, 2022
When the new `ignore-empty-path-segments` feature is enabled, multiple leading slashes at the start of the path are ignored (the first segment starts after them), and multiple slashes at the end of any matched segment are ignored (so the next segment starts after them).  In addition, the `end` filter will ignore multiple slashes that follow the final segment. Both the `fullpath` and `tail` filters will still return any multiple slashes in their matched text, but their `segments` iterator will ignore the empty segments (in fact it does this today even without this feature being set).

This change does _not_ include this feature in the list of default features.

This change includes path filter testing on paths with multiple slashes in them.

This change fixes seanmonstar#738.
@brotskydotcom
Copy link

I have submitted PR #993 which adds a feature ignore-empty-path-segments that works around this problem by having the path segment filters ignore multiple slashes between segments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants