{"action":"created","comment":{"url":"https://api.github.com/repos/hanami/router/pulls/comments/52432541","id":52432541,"diff_hunk":"@@ -24,4 +24,60 @@ def rack_request\n       env['SCRIPT_NAME'].to_s.must_equal '/post'\n     end\n   end\n+\n+  describe '#rewrite_partial_path_info' do\n+    describe 'when from partial match' do\n+      it 'sets PATH_INFO correctly' do\n+        request_env = nil\n+        router = Hanami::Routing::HttpRouter.new\n+        router.add(\"/sidekiq*\").to { |env| request_env = env; [200, {}, []] }","path":"test/routing/http_router_test.rb","position":10,"original_position":10,"commit_id":"bd4077ddec8e8251c2284256337ab6f6da5239e7","original_commit_id":"bd4077ddec8e8251c2284256337ab6f6da5239e7","user":{"login":"jodosha","id":5089,"avatar_url":"https://avatars.githubusercontent.com/u/5089?v=3","gravatar_id":"","url":"https://api.github.com/users/jodosha","html_url":"https://github.com/jodosha","followers_url":"https://api.github.com/users/jodosha/followers","following_url":"https://api.github.com/users/jodosha/following{/other_user}","gists_url":"https://api.github.com/users/jodosha/gists{/gist_id}","starred_url":"https://api.github.com/users/jodosha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodosha/subscriptions","organizations_url":"https://api.github.com/users/jodosha/orgs","repos_url":"https://api.github.com/users/jodosha/repos","events_url":"https://api.github.com/users/jodosha/events{/privacy}","received_events_url":"https://api.github.com/users/jodosha/received_events","type":"User","site_admin":false},"body":"@cyphactor :+1: to @joneslee85 comment","created_at":"2016-02-10T09:23:51Z","updated_at":"2016-02-10T09:23:51Z","html_url":"https://github.com/hanami/router/pull/91#discussion_r52432541","pull_request_url":"https://api.github.com/repos/hanami/router/pulls/91","_links":{"self":{"href":"https://api.github.com/repos/hanami/router/pulls/comments/52432541"},"html":{"href":"https://github.com/hanami/router/pull/91#discussion_r52432541"},"pull_request":{"href":"https://api.github.com/repos/hanami/router/pulls/91"}}},"pull_request":{"url":"https://api.github.com/repos/hanami/router/pulls/91","id":58841931,"html_url":"https://github.com/hanami/router/pull/91","diff_url":"https://github.com/hanami/router/pull/91.diff","patch_url":"https://github.com/hanami/router/pull/91.patch","issue_url":"https://api.github.com/repos/hanami/router/issues/91","number":91,"state":"open","locked":false,"title":"Fix empty script name with partial match route bug","user":{"login":"cyphactor","id":24400,"avatar_url":"https://avatars.githubusercontent.com/u/24400?v=3","gravatar_id":"","url":"https://api.github.com/users/cyphactor","html_url":"https://github.com/cyphactor","followers_url":"https://api.github.com/users/cyphactor/followers","following_url":"https://api.github.com/users/cyphactor/following{/other_user}","gists_url":"https://api.github.com/users/cyphactor/gists{/gist_id}","starred_url":"https://api.github.com/users/cyphactor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyphactor/subscriptions","organizations_url":"https://api.github.com/users/cyphactor/orgs","repos_url":"https://api.github.com/users/cyphactor/repos","events_url":"https://api.github.com/users/cyphactor/events{/privacy}","received_events_url":"https://api.github.com/users/cyphactor/received_events","type":"User","site_admin":false},"body":"Why you made the change:\r\n\r\nI made this change so that SCRIPT_NAME and PATH_INFO would be set\r\nappropriately in the scenario where a partial match route is used.\r\n\r\nHow the change addresses the need:\r\n\r\nThere is an issue with the current version of rewrite_partial_path_info\r\nin HttpRouter where it does not set SCRIPT_NAME appropriately. When the\r\nrequest environments PATH_INFO is set, it causes the\r\nrequest.rack_request.path_info helper return the updated version, not\r\nthe original. This is requst.rack_request.path_info eventually just\r\nreads the PATH_INFO value out of the request environment. As a side\r\neffect of this, the original code would always set the SCRIPT_NAME to \"\"\r\nbecause it would be slicing from request.rack_request.path_info[0, 0] in\r\nactuality.\r\n\r\nThis change resolves this issue by first temporarily storing a dup of\r\nthe original path_info and using that to determine the end index for the\r\nSCRIPT_NAME. This change also handles setting SCRIPT_NAME correctly for\r\nthe somewhat unique but common case of matching the partial match\r\nexactly.\r\n\r\nThis change also includes a fix to handle maintaining URI encoded values\r\nin PATH_INFO and SCRIPT_INFO. Currently, there is a problem where\r\nbecause the method uses the request.path helper HttpRouter provides,\r\nwhich URI.decodes the string, it screws up both the PATH_INFO and\r\nSCRIPT_NAME. Therefore, I URI.encode it back appropriately before any\r\noffsetting, or setting is done.\r\n\r\nI have also added tests for each of these cases as I couldn't find any\r\ntests covering this before.\r\n\r\nThis fixes issue #87.","created_at":"2016-02-10T02:53:00Z","updated_at":"2016-02-10T09:23:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b0cdc9aa82820cb351683bdbe18ebac6a70d42b","assignee":null,"milestone":{"url":"https://api.github.com/repos/hanami/router/milestones/13","html_url":"https://github.com/hanami/router/milestones/next","labels_url":"https://api.github.com/repos/hanami/router/milestones/13/labels","id":1565831,"number":13,"title":"next","description":"","creator":{"login":"jodosha","id":5089,"avatar_url":"https://avatars.githubusercontent.com/u/5089?v=3","gravatar_id":"","url":"https://api.github.com/users/jodosha","html_url":"https://github.com/jodosha","followers_url":"https://api.github.com/users/jodosha/followers","following_url":"https://api.github.com/users/jodosha/following{/other_user}","gists_url":"https://api.github.com/users/jodosha/gists{/gist_id}","starred_url":"https://api.github.com/users/jodosha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodosha/subscriptions","organizations_url":"https://api.github.com/users/jodosha/orgs","repos_url":"https://api.github.com/users/jodosha/repos","events_url":"https://api.github.com/users/jodosha/events{/privacy}","received_events_url":"https://api.github.com/users/jodosha/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2016-02-05T16:26:30Z","updated_at":"2016-02-10T05:27:38Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/hanami/router/pulls/91/commits","review_comments_url":"https://api.github.com/repos/hanami/router/pulls/91/comments","review_comment_url":"https://api.github.com/repos/hanami/router/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hanami/router/issues/91/comments","statuses_url":"https://api.github.com/repos/hanami/router/statuses/bd4077ddec8e8251c2284256337ab6f6da5239e7","head":{"label":"Acornsgrow:fix_empty_script_name_with_partial_match_route_bug","ref":"fix_empty_script_name_with_partial_match_route_bug","sha":"bd4077ddec8e8251c2284256337ab6f6da5239e7","user":{"login":"Acornsgrow","id":3977038,"avatar_url":"https://avatars.githubusercontent.com/u/3977038?v=3","gravatar_id":"","url":"https://api.github.com/users/Acornsgrow","html_url":"https://github.com/Acornsgrow","followers_url":"https://api.github.com/users/Acornsgrow/followers","following_url":"https://api.github.com/users/Acornsgrow/following{/other_user}","gists_url":"https://api.github.com/users/Acornsgrow/gists{/gist_id}","starred_url":"https://api.github.com/users/Acornsgrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Acornsgrow/subscriptions","organizations_url":"https://api.github.com/users/Acornsgrow/orgs","repos_url":"https://api.github.com/users/Acornsgrow/repos","events_url":"https://api.github.com/users/Acornsgrow/events{/privacy}","received_events_url":"https://api.github.com/users/Acornsgrow/received_events","type":"Organization","site_admin":false},"repo":{"id":51340514,"name":"router","full_name":"Acornsgrow/router","owner":{"login":"Acornsgrow","id":3977038,"avatar_url":"https://avatars.githubusercontent.com/u/3977038?v=3","gravatar_id":"","url":"https://api.github.com/users/Acornsgrow","html_url":"https://github.com/Acornsgrow","followers_url":"https://api.github.com/users/Acornsgrow/followers","following_url":"https://api.github.com/users/Acornsgrow/following{/other_user}","gists_url":"https://api.github.com/users/Acornsgrow/gists{/gist_id}","starred_url":"https://api.github.com/users/Acornsgrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Acornsgrow/subscriptions","organizations_url":"https://api.github.com/users/Acornsgrow/orgs","repos_url":"https://api.github.com/users/Acornsgrow/repos","events_url":"https://api.github.com/users/Acornsgrow/events{/privacy}","received_events_url":"https://api.github.com/users/Acornsgrow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Acornsgrow/router","description":"Ruby/Rack HTTP router","fork":true,"url":"https://api.github.com/repos/Acornsgrow/router","forks_url":"https://api.github.com/repos/Acornsgrow/router/forks","keys_url":"https://api.github.com/repos/Acornsgrow/router/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Acornsgrow/router/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Acornsgrow/router/teams","hooks_url":"https://api.github.com/repos/Acornsgrow/router/hooks","issue_events_url":"https://api.github.com/repos/Acornsgrow/router/issues/events{/number}","events_url":"https://api.github.com/repos/Acornsgrow/router/events","assignees_url":"https://api.github.com/repos/Acornsgrow/router/assignees{/user}","branches_url":"https://api.github.com/repos/Acornsgrow/router/branches{/branch}","tags_url":"https://api.github.com/repos/Acornsgrow/router/tags","blobs_url":"https://api.github.com/repos/Acornsgrow/router/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Acornsgrow/router/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Acornsgrow/router/git/refs{/sha}","trees_url":"https://api.github.com/repos/Acornsgrow/router/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Acornsgrow/router/statuses/{sha}","languages_url":"https://api.github.com/repos/Acornsgrow/router/languages","stargazers_url":"https://api.github.com/repos/Acornsgrow/router/stargazers","contributors_url":"https://api.github.com/repos/Acornsgrow/router/contributors","subscribers_url":"https://api.github.com/repos/Acornsgrow/router/subscribers","subscription_url":"https://api.github.com/repos/Acornsgrow/router/subscription","commits_url":"https://api.github.com/repos/Acornsgrow/router/commits{/sha}","git_commits_url":"https://api.github.com/repos/Acornsgrow/router/git/commits{/sha}","comments_url":"https://api.github.com/repos/Acornsgrow/router/comments{/number}","issue_comment_url":"https://api.github.com/repos/Acornsgrow/router/issues/comments{/number}","contents_url":"https://api.github.com/repos/Acornsgrow/router/contents/{+path}","compare_url":"https://api.github.com/repos/Acornsgrow/router/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Acornsgrow/router/merges","archive_url":"https://api.github.com/repos/Acornsgrow/router/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Acornsgrow/router/downloads","issues_url":"https://api.github.com/repos/Acornsgrow/router/issues{/number}","pulls_url":"https://api.github.com/repos/Acornsgrow/router/pulls{/number}","milestones_url":"https://api.github.com/repos/Acornsgrow/router/milestones{/number}","notifications_url":"https://api.github.com/repos/Acornsgrow/router/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Acornsgrow/router/labels{/name}","releases_url":"https://api.github.com/repos/Acornsgrow/router/releases{/id}","deployments_url":"https://api.github.com/repos/Acornsgrow/router/deployments","created_at":"2016-02-09T01:45:42Z","updated_at":"2016-02-09T01:45:42Z","pushed_at":"2016-02-10T02:48:50Z","git_url":"git://github.com/Acornsgrow/router.git","ssh_url":"git@github.com:Acornsgrow/router.git","clone_url":"https://github.com/Acornsgrow/router.git","svn_url":"https://github.com/Acornsgrow/router","homepage":"http://hanamirb.org","size":399,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hanami:master","ref":"master","sha":"add3706a951ef0fe5aea84b46a61e80000bc8fdc","user":{"login":"hanami","id":3210273,"avatar_url":"https://avatars.githubusercontent.com/u/3210273?v=3","gravatar_id":"","url":"https://api.github.com/users/hanami","html_url":"https://github.com/hanami","followers_url":"https://api.github.com/users/hanami/followers","following_url":"https://api.github.com/users/hanami/following{/other_user}","gists_url":"https://api.github.com/users/hanami/gists{/gist_id}","starred_url":"https://api.github.com/users/hanami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanami/subscriptions","organizations_url":"https://api.github.com/users/hanami/orgs","repos_url":"https://api.github.com/users/hanami/repos","events_url":"https://api.github.com/users/hanami/events{/privacy}","received_events_url":"https://api.github.com/users/hanami/received_events","type":"Organization","site_admin":false},"repo":{"id":10696882,"name":"router","full_name":"hanami/router","owner":{"login":"hanami","id":3210273,"avatar_url":"https://avatars.githubusercontent.com/u/3210273?v=3","gravatar_id":"","url":"https://api.github.com/users/hanami","html_url":"https://github.com/hanami","followers_url":"https://api.github.com/users/hanami/followers","following_url":"https://api.github.com/users/hanami/following{/other_user}","gists_url":"https://api.github.com/users/hanami/gists{/gist_id}","starred_url":"https://api.github.com/users/hanami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanami/subscriptions","organizations_url":"https://api.github.com/users/hanami/orgs","repos_url":"https://api.github.com/users/hanami/repos","events_url":"https://api.github.com/users/hanami/events{/privacy}","received_events_url":"https://api.github.com/users/hanami/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hanami/router","description":"Ruby/Rack HTTP router","fork":false,"url":"https://api.github.com/repos/hanami/router","forks_url":"https://api.github.com/repos/hanami/router/forks","keys_url":"https://api.github.com/repos/hanami/router/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hanami/router/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hanami/router/teams","hooks_url":"https://api.github.com/repos/hanami/router/hooks","issue_events_url":"https://api.github.com/repos/hanami/router/issues/events{/number}","events_url":"https://api.github.com/repos/hanami/router/events","assignees_url":"https://api.github.com/repos/hanami/router/assignees{/user}","branches_url":"https://api.github.com/repos/hanami/router/branches{/branch}","tags_url":"https://api.github.com/repos/hanami/router/tags","blobs_url":"https://api.github.com/repos/hanami/router/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hanami/router/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hanami/router/git/refs{/sha}","trees_url":"https://api.github.com/repos/hanami/router/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hanami/router/statuses/{sha}","languages_url":"https://api.github.com/repos/hanami/router/languages","stargazers_url":"https://api.github.com/repos/hanami/router/stargazers","contributors_url":"https://api.github.com/repos/hanami/router/contributors","subscribers_url":"https://api.github.com/repos/hanami/router/subscribers","subscription_url":"https://api.github.com/repos/hanami/router/subscription","commits_url":"https://api.github.com/repos/hanami/router/commits{/sha}","git_commits_url":"https://api.github.com/repos/hanami/router/git/commits{/sha}","comments_url":"https://api.github.com/repos/hanami/router/comments{/number}","issue_comment_url":"https://api.github.com/repos/hanami/router/issues/comments{/number}","contents_url":"https://api.github.com/repos/hanami/router/contents/{+path}","compare_url":"https://api.github.com/repos/hanami/router/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hanami/router/merges","archive_url":"https://api.github.com/repos/hanami/router/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hanami/router/downloads","issues_url":"https://api.github.com/repos/hanami/router/issues{/number}","pulls_url":"https://api.github.com/repos/hanami/router/pulls{/number}","milestones_url":"https://api.github.com/repos/hanami/router/milestones{/number}","notifications_url":"https://api.github.com/repos/hanami/router/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hanami/router/labels{/name}","releases_url":"https://api.github.com/repos/hanami/router/releases{/id}","deployments_url":"https://api.github.com/repos/hanami/router/deployments","created_at":"2013-06-14T20:07:26Z","updated_at":"2016-02-05T09:45:58Z","pushed_at":"2016-02-10T02:53:01Z","git_url":"git://github.com/hanami/router.git","ssh_url":"git@github.com:hanami/router.git","clone_url":"https://github.com/hanami/router.git","svn_url":"https://github.com/hanami/router","homepage":"http://hanamirb.org","size":421,"stargazers_count":232,"watchers_count":232,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":2,"forks":54,"open_issues":2,"watchers":232,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hanami/router/pulls/91"},"html":{"href":"https://github.com/hanami/router/pull/91"},"issue":{"href":"https://api.github.com/repos/hanami/router/issues/91"},"comments":{"href":"https://api.github.com/repos/hanami/router/issues/91/comments"},"review_comments":{"href":"https://api.github.com/repos/hanami/router/pulls/91/comments"},"review_comment":{"href":"https://api.github.com/repos/hanami/router/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hanami/router/pulls/91/commits"},"statuses":{"href":"https://api.github.com/repos/hanami/router/statuses/bd4077ddec8e8251c2284256337ab6f6da5239e7"}}}}