caddyhttp: fix route sort by comparing paths without wildcard if they don't shar…#7015
caddyhttp: fix route sort by comparing paths without wildcard if they don't shar…#7015
Conversation
…e the same prefix
|
Nice. Could you add an adapt test for this? |
|
I think there is still a difference between the Docs and the implementation From the doc: but if we have a caddy config like: :9991 {
route /foo* {
}
route /fob* {
}
route /foo {
}
}the result of "routes": [
{
"match": [
{
"path": [
"/foo*"
]
}
],
"handle": [
{
"handler": "subroute"
}
]
},
{
"match": [
{
"path": [
"/fob*"
]
}
],
"handle": [
{
"handler": "subroute"
}
]
},
{
"match": [
{
"path": [
"/foo"
]
}
],
"handle": [
{
"handler": "subroute"
}
]
}
]so here we can see that the result is |
|
Right, |
|
It's now fixed by ordering routes lexically if the paths have the same length. |
|
@Hellio404 Want to give it one more try and then we can merge it? Thank you very much @WeidiDeng !! |
|
@mholt I did few tests now it is working as expected |
mholt
left a comment
There was a problem hiding this comment.
That's great! Thank you both :D
|
I'd still like an adapt test to cover this to make sure we don't break it again in the future |
|
Yeah that'd probably be good. It's subtle code. |
…#7015) * fix route sort by comparing paths without wildcard if they don't share the same prefix * sort lexically if paths have the same length
…e the same prefix
Fix 7012.