[Router] Compose and restore SCRIPT_NAME for mounted Rack apps - #356
Merged
rsamoilov merged 1 commit intoJul 21, 2026
Merged
Conversation
Compose SCRIPT_NAME from the existing prefix plus the mount path for mounted Rack apps, and restore the original Rack env values after the mounted app returns. Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Issue #355 reported that mounted Rack apps overwrite
SCRIPT_NAMEwith only the mount path and do not restore the original value after the mounted app returns.This PR updates router mount handling to compose
SCRIPT_NAMEfrom the existing prefix plus the mount path, while still passing the mounted subpath asPATH_INFO.It also restores the original
SCRIPT_NAMEandPATH_INFOafter the mounted app returns, adds a regression spec that covers both behaviors, and adds a changelog entry for the fix.Before the fix:
SCRIPT_NAME="/outer",PATH_INFO="/rack_app/index"SCRIPT_NAME="/rack_app",PATH_INFO="/index"SCRIPT_NAME="/rack_app",PATH_INFO="/rack_app/index"After the fix:
SCRIPT_NAME="/outer",PATH_INFO="/rack_app/index"SCRIPT_NAME="/outer/rack_app",PATH_INFO="/index"SCRIPT_NAME="/outer",PATH_INFO="/rack_app/index"Closes #355.
Checklist:
bundle exec rspec spec/router/mount_spec.rb.bundle exec rspec spec/router.bundle exec rspec.