Skip to content

Rack::RouteInference: MAX_NUMBER_OF_SEGMENTS priority #5325

@lloeki

Description

@lloeki

Good catch.

The original version indeed did a .split('/', MAX_NUMBER_OF_SEGMENTS + 1), doubled with a .first(MAX_NUMBER_OF_SEGMENTS) (the latter which confused the hell out of me), so it would indeed cut before processing.

That said it seems like an oddball: indeed RFC3986 specifies that path components between / shall be segment-nz i.e at least 1 pchar.

Since the intent is to capture routes it seems like "empty segments" (which is a thing that does not exist according to the RFC) i.e a sequence of two or more / ought to be normalised to a single /, and we then take MAX_NUMBER_OF_SEGMENTS meaningful ones.

@y9v do you feel we should swap next and break order?

Originally posted by @lloeki in #5319 (comment)

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