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

Add a filter that normalizes url paths by removing trailing slashes and empty path segments #3236

Open
mvalkon opened this issue Sep 19, 2024 · 0 comments · May be fixed by #3237
Open

Add a filter that normalizes url paths by removing trailing slashes and empty path segments #3236

mvalkon opened this issue Sep 19, 2024 · 0 comments · May be fixed by #3237

Comments

@mvalkon
Copy link
Member

mvalkon commented Sep 19, 2024

Is your feature request related to a problem? Please describe.

At Zalando we have defined a guiding rule for API designers to specify APIs without empty path segments and trailing slashes

However, client implementations in production may be configured poorly to contain trailing slashes which the rule also suggests the server to protect against by

We recommend to implement services robust against clients not following this rule. All services
should normalize request paths before processing by removing duplicate and trailing slashes.

This can be implemented in a simple filter in Skipper.

Describe the solution you would like
A normalizePath()-filter which transforms URLs to contain no empty path segments and no trailing slashes.

URLs such as

GET /orders/{order-id}
GET /orders/{order-id}/
GET /orders//{order-id}

should be normalized to /orders/{order-id}.

Describe alternatives you've considered (optional)
We can achieve this by using the existing modPath-filter and a regular expression, which can be sufficient but also lead to incidents where the regular expression is poorly written and breaks production environment.

Additional context (optional)
Add any other context or screenshots about the feature request here.

Would you like to work on it?
Yes

@mvalkon mvalkon linked a pull request Sep 19, 2024 that will close this issue
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 a pull request may close this issue.

1 participant