-
Hartley McGuire authored
When routing a request, `#find_routes` will iterate through potential routes for the request and yield them to the passed block. `#serve` and `#recognize` both used `#find_routes`, but ended up handling things slightly differently. Both methods would modify the `script_name` and `path_info` of the request if the current route is not anchored. However, only `#serve` used `#chomp` and would restore the request's original `script_name` and `path_info` after each iteration. This inconsistency can cause issues as `#recognize` can end up not matching them even though `#serve` would. This commit fixes the issue by unifying more of the implementations of `#serve` and `#recognize`. Now, `#find_routes` implements the mutation/restoration of request params for both `#serve` and `#recognize` so that their behavior is consistent and request mutation isn't leaked between iterations. One test had to be changed because it depended on the request mutation leaking outside of `#recognize`, so it was updated to make assertions during `#recognize` instead.
Hartley McGuire authoredWhen routing a request, `#find_routes` will iterate through potential routes for the request and yield them to the passed block. `#serve` and `#recognize` both used `#find_routes`, but ended up handling things slightly differently. Both methods would modify the `script_name` and `path_info` of the request if the current route is not anchored. However, only `#serve` used `#chomp` and would restore the request's original `script_name` and `path_info` after each iteration. This inconsistency can cause issues as `#recognize` can end up not matching them even though `#serve` would. This commit fixes the issue by unifying more of the implementations of `#serve` and `#recognize`. Now, `#find_routes` implements the mutation/restoration of request params for both `#serve` and `#recognize` so that their behavior is consistent and request mutation isn't leaked between iterations. One test had to be changed because it depended on the request mutation leaking outside of `#recognize`, so it was updated to make assertions during `#recognize` instead.
Loading