Commit 287087c
committed
Fix prefix-suffix conflict due to insertion order of trailing slashes
When inserting route parameters with static suffixes, `matchit` checked
for conflicts between newly inserted suffixes and existing ones. It had
an explicit exception to allow a new suffix that only differed by an
extra trailing slash (e.g., `o/` vs existing `o`).
However, this check only evaluated one direction: if the *new* suffix
was longer than the *existing* suffix. If the routes were inserted in
the reverse order (e.g., `o/` inserted first, then `o` inserted second),
the router incorrectly flagged them as a prefix-suffix conflict.
This commit makes the trailing slash check bidirectional by adding an
`else` branch to verify if the *existing* suffix is the one with the
extra trailing slash, resolving the insertion order dependency.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>1 parent 87804fe commit 287087c
2 files changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
0 commit comments