Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/http_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def rewrite_partial_path_info(env, request)
env['PATH_INFO'] = "/"
env['SCRIPT_NAME'] += path_info_before
else
env['PATH_INFO'] = "/#{request.path.join('/')}"
env['PATH_INFO'] = "/#{URI.encode(request.path.join('/'))}"
env['SCRIPT_NAME'] += path_info_before[0, path_info_before.size - env['PATH_INFO'].size]
end
end
Expand Down
18 changes: 18 additions & 0 deletions test/rack/test_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,22 @@ def test_script_name_from_partial_match_of_single
router.call(Rack::MockRequest.env_for("/sidekiq"))
assert_equal('/sidekiq', request_env['SCRIPT_NAME'])
end

def test_path_info_with_encoded_request_path
request_env = nil
router do
add("/sidekiq*").to { |env| request_env = env; [200, {}, []] }
end
router.call(Rack::MockRequest.env_for("/sidekiq/queues/some%20path"))
assert_equal('/queues/some%20path', request_env['PATH_INFO'])
end

def test_script_name_with_encoded_request_path
request_env = nil
router do
add("/sidekiq*").to { |env| request_env = env; [200, {}, []] }
end
router.call(Rack::MockRequest.env_for("/sidekiq/queues/some%20path"))
assert_equal('/sidekiq', request_env['SCRIPT_NAME'])
end
end