Skip to content

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

Open
@mvalkon

Description

@mvalkon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions