Skip to content

Commit

Permalink
URL escape GitHub username
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hunt committed Oct 25, 2013
1 parent 3435640 commit 12d77d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/github/auth/keys_client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'cgi'
require 'httparty'

module Github::Auth
Expand All @@ -21,7 +22,7 @@ def initialize(options = {})
options = DEFAULT_OPTIONS.merge options
raise UsernameRequiredError unless options.fetch :username

@username = options.fetch :username
@username = CGI.escape(options.fetch :username)
@hostname = options.fetch :hostname
end

Expand Down
5 changes: 5 additions & 0 deletions spec/unit/github/auth/keys_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
keys_client = described_class.new username: username
expect(keys_client.username).to eq username
end

it 'url escapes the username' do
keys_client = described_class.new username: 'spaces are !o.k.'
expect(keys_client.username).to eq 'spaces+are+%21o.k.'
end
end

describe '#keys' do
Expand Down

0 comments on commit 12d77d6

Please sign in to comment.