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

fix unescaping multiple slashes in branch name in URLs

上级 b00aa037
......@@ -73,9 +73,9 @@ Feature: hub browse
Scenario: Complex branch
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`
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
Given I am in "git://github.com/defunkt/hub.wiki.git" git repo
......
......@@ -649,9 +649,9 @@ module Hub
# $ hub browse -- wiki
path = case subpage = args.shift
when 'commits'
"/commits/#{CGI.escape(branch.short_name).sub("%2F", "/")}"
"/commits/#{branch_in_url(branch)}"
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
"/#{subpage}"
end
......@@ -660,6 +660,11 @@ module Hub
end
end
def branch_in_url(branch)
require 'CGI'
CGI.escape(branch.short_name).gsub("%2F", "/")
end
# $ hub compare 1.0..fix
# > open https://github.com/CURRENT_REPO/compare/1.0...fix
# $ hub compare refactor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册