Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
fix(proxy) prioritize longer regex path matches #5667
Let’s say we have two Routes, each with a single path and otherwise identically-configured:
In the current behavior, unless
With non-regex paths, Kong currently (very helpfully) defaults to giving precedence/priority to longer paths. This is a great default.
This change simply makes the same true for regex paths, which is a more reasonable/predictable default (compared to created-time based priority, which is implicit and undesirable).
`regex_priority` obviously still applies and takes precedence, but just like we prioritize longer matches for non-regex paths, prioritizing longer paths in the regex case, as well, is a more reasonable/predictable default (otherwise we fall back to created-time based priority, which is implicit and undesirable).
@bungle Good point. Isn’t that significantly more 'intrusive' to implement, though?
To be clear, I don’t at all disagree that the semantic considering real match lengths is preferable—but it seems like basing this on regex length, while not ideal, is still preferable to the current behavior.
(Also, just noticed a couple of the tests need to be updated. Will do that if the approach seems reasonable to you).
@chrisaljoudi while I agree that created-time is not a great default criteria (and that's of course why the
Running all regexes and applying the longest match would IMO make more sense, I think, and yes, the implementation would look very different, etc. (Though
With that in mind, what do you guys think if the logic was to default
Again, this would still be in a major version, just wondering what you semantically think of that vs. length (trying to support the use-case exemplified above for more ‘specific’/drilled-down parameterized routes being matched first).
Number of capture groups is one idea, and another is the number of ‘path segments’ (though that’s less deterministic as you point out, because a regex may match multiple segments).