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)
Originally posted by @lloeki in #5319 (comment)