skipper icon indicating copy to clipboard operation
skipper copied to clipboard

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

Open mvalkon opened this issue 1 year ago • 0 comments

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 avatar Sep 19 '24 09:09 mvalkon