Skip to content

Commit b1ed626

Browse files
committed
Merge pull request #20 from chrishunt/escape-username
URL escape GitHub username
2 parents 3435640 + 12d77d6 commit b1ed626

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/github/auth/keys_client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'cgi'
12
require 'httparty'
23

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

24-
@username = options.fetch :username
25+
@username = CGI.escape(options.fetch :username)
2526
@hostname = options.fetch :hostname
2627
end
2728

spec/unit/github/auth/keys_client_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
keys_client = described_class.new username: username
3434
expect(keys_client.username).to eq username
3535
end
36+
37+
it 'url escapes the username' do
38+
keys_client = described_class.new username: 'spaces are !o.k.'
39+
expect(keys_client.username).to eq 'spaces+are+%21o.k.'
40+
end
3641
end
3742

3843
describe '#keys' do

0 commit comments

Comments
 (0)