Skip to content

Commit

Permalink
Merge pull request #146 from timcraft/fix-character-class-warnings
Browse files Browse the repository at this point in the history
Fix character class bug/warnings
  • Loading branch information
sporkmonger committed Jan 21, 2014
2 parents 03f4923 + 69a6ba7 commit ea3c89a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/addressable/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def self.normalize_component(component, character_class=
end
if character_class.kind_of?(String)
leave_re = if leave_encoded.length > 0
character_class << '%'
character_class = "#{character_class}%" unless character_class.include?('%')

"|%(?!#{leave_encoded.chars.map do |char|
seq = char.unpack('C*').map { |c| '%02x' % c }.join
Expand Down
10 changes: 10 additions & 0 deletions spec/addressable/uri_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5372,6 +5372,16 @@ def to_str
Addressable::URI.normalize_component("%58X%59Y%5AZ", "0-9a-zXY", "Y").should ==
"XX%59Y%5A%5A"
end

it "should not modify the character class" do
character_class = "0-9a-zXY"

character_class_copy = character_class.dup

Addressable::URI.normalize_component("%58X%59Y%5AZ", character_class, "Y")

character_class.should == character_class_copy
end
end

describe Addressable::URI, "when encoding a string with existing encodings to upcase" do
Expand Down

0 comments on commit ea3c89a

Please sign in to comment.