Skip to content

Commit 2f85356

Browse files
authored
Fix unescape (#25)
1 parent c06b62e commit 2f85356

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/protocol/http/url.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def self.escape(string, encoding = string.encoding)
3333
# Unescapes a percent encoded string.
3434
def self.unescape(string, encoding = string.encoding)
3535
string.b.gsub(/%(\h\h)/) do |hex|
36-
Integer(hex, 16).chr
36+
Integer($1, 16).chr
3737
end.force_encoding(encoding)
3838
end
3939

spec/protocol/http/url_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,10 @@
7474
end.to raise_error(/Key length exceeded/)
7575
end
7676
end
77+
78+
describe '.unescape' do
79+
it "succeds with hex characters" do
80+
expect(Protocol::HTTP::URL.unescape("%3A")).to be == ":"
81+
end
82+
end
7783
end

0 commit comments

Comments
 (0)