Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Escape ref in archive_link #1375

Merged
merged 5 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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/octokit/client/contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def delete_contents(repo, path, message, sha, options = {})
# @example Get archive link for octokit/octokit.rb
# Octokit.archive_link("octokit/octokit.rb")
def archive_link(repo, options={})
repo_ref = options.delete :ref
repo_ref = ERB::Util.url_encode(options.delete :ref)
format = (options.delete :format) || 'tarball'
url = "#{Repository.path repo}/#{format}/#{repo_ref}"

Expand Down
6 changes: 6 additions & 0 deletions spec/octokit/client/contents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
expect(archive_link).to eq('https://codeload.github.com/octokit/octokit.rb/legacy.tar.gz/master')
assert_requested :head, github_url("/repos/octokit/octokit.rb/tarball/master")
end

it "does not raise for ref with unicode" do
request = stub_head("repos/octokit/octokit.rb/tarball/%F0%9F%90%99%F0%9F%90%B1")
@client.archive_link("octokit/octokit.rb", :ref => "🐙🐱")
assert_requested request
end
end # .archive_link

# TODO: Make the following specs idempotent
Expand Down