提交 dd5f7153 编写于 作者: M Mislav Marohnić

fix unescaping multiple slashes in branch name in URLs

上级 b00aa037
...@@ -73,9 +73,9 @@ Feature: hub browse ...@@ -73,9 +73,9 @@ Feature: hub browse
Scenario: Complex branch Scenario: Complex branch
Given I am in "git://github.com/mislav/dotfiles.git" git repo Given I am in "git://github.com/mislav/dotfiles.git" git repo
And I am on the "foo/bar" branch with upstream "origin/baz/qux" And I am on the "foo/bar" branch with upstream "origin/baz/qux/moo"
When I successfully run `hub browse` When I successfully run `hub browse`
Then "open https://github.com/mislav/dotfiles/tree/baz/qux" should be run Then "open https://github.com/mislav/dotfiles/tree/baz/qux/moo" should be run
Scenario: Wiki repo Scenario: Wiki repo
Given I am in "git://github.com/defunkt/hub.wiki.git" git repo Given I am in "git://github.com/defunkt/hub.wiki.git" git repo
......
...@@ -649,9 +649,9 @@ module Hub ...@@ -649,9 +649,9 @@ module Hub
# $ hub browse -- wiki # $ hub browse -- wiki
path = case subpage = args.shift path = case subpage = args.shift
when 'commits' when 'commits'
"/commits/#{CGI.escape(branch.short_name).sub("%2F", "/")}" "/commits/#{branch_in_url(branch)}"
when 'tree', NilClass when 'tree', NilClass
"/tree/#{CGI.escape(branch.short_name).sub("%2F", "/")}" if branch and !branch.master? "/tree/#{branch_in_url(branch)}" if branch and !branch.master?
else else
"/#{subpage}" "/#{subpage}"
end end
...@@ -660,6 +660,11 @@ module Hub ...@@ -660,6 +660,11 @@ module Hub
end end
end end
def branch_in_url(branch)
require 'CGI'
CGI.escape(branch.short_name).gsub("%2F", "/")
end
# $ hub compare 1.0..fix # $ hub compare 1.0..fix
# > open https://github.com/CURRENT_REPO/compare/1.0...fix # > open https://github.com/CURRENT_REPO/compare/1.0...fix
# $ hub compare refactor # $ hub compare refactor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册