Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

### Motivation / Background #2084

Closed
4 tasks done
xXxrAinSonic opened this issue Feb 16, 2025 · 1 comment
Closed
4 tasks done

### Motivation / Background #2084

xXxrAinSonic opened this issue Feb 16, 2025 · 1 comment

Comments

@xXxrAinSonic
Copy link

xXxrAinSonic commented Feb 16, 2025

Motivation / Background

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.

Detail

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.

Additional information

Fixes #31152

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Originally posted by @skipkayhil in rails/rails#54550

@xXxrAinSonic
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant