Skip to content

Incorrect route matched when part of URL overlaps #57312

@mnastalski

Description

@mnastalski

Laravel Version

12.33.0

PHP Version

8.3

Database Driver & Version

No response

Description

Most likely related to #56920, starting from 12.29.0, some parameters seem to get ignored as long as the first found route partially matches the path. Query string is created for the remaining parameters.

Steps To Reproduce

Assuming the following declaration in routes (and yes, these are from laravel nova, v5.5):

Route::get('/{resource}/attachable/{field}', MyController::class);
Route::get('/{resource}/{resourceId}/attachable/{field}', MyController::class);

Get the URL using action():

action(MyController::class, [
    'resource' => 'posts',
    'resourceId' => 1,
    'field' => 'category',
    'foo' => 'bar',
]);

Pre 12.29.0 the above would match the second route and result in:
(...)/posts/1/attachable/category?foo=bar

While from 12.29.0 it matches the first route and results in:
(...)/posts/attachable/category?resourceId=1&foo=bar"

It's a bit of an edge case but I would expect it to still match the second route

Repository with the above should it be needed:
https://github.com/mnastalski/routing-reproduction/blob/master/routes/web.php
https://github.com/mnastalski/routing-reproduction/blob/master/tests/Feature/ExampleTest.php

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions