Permalink
Browse files

Fixed port encoding issue. Closes #103.

  • Loading branch information...
1 parent dc1871b commit 654cdf03304918d2cd7c6751e32ee55b88064a40 @sporkmonger committed Feb 4, 2013
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/addressable/uri.rb
  2. +14 −0 spec/addressable/uri_spec.rb
@@ -571,7 +571,7 @@ def self.normalized_encode(uri, return_type=String)
:user => self.unencode_component(uri_object.user),
:password => self.unencode_component(uri_object.password),
:host => self.unencode_component(uri_object.host),
- :port => uri_object.port,
+ :port => (uri_object.port.nil? ? nil : uri_object.port.to_s),
:path => self.unencode_component(uri_object.path),
:query => self.unencode_component(uri_object.query),
:fragment => self.unencode_component(uri_object.fragment)
@@ -1840,6 +1840,13 @@ def to_s
it "should have an origin of 'http://example.com'" do
@uri.origin.should == 'http://example.com'
end
+
+ it "should not change if encoded with the normalizing algorithm" do
+ Addressable::URI.normalized_encode(@uri).to_s.should ==
+ "http://example.com:80/"
+ Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
+ "http://example.com:80/"
+ end
end
describe Addressable::URI, "when parsed from " +
@@ -1949,6 +1956,13 @@ def to_s
it "should have an origin of 'http://example.com:8080'" do
@uri.origin.should == 'http://example.com:8080'
end
+
+ it "should not change if encoded with the normalizing algorithm" do
+ Addressable::URI.normalized_encode(@uri).to_s.should ==
+ "http://example.com:8080/"
+ Addressable::URI.normalized_encode(@uri, Addressable::URI).to_s.should ===
+ "http://example.com:8080/"
+ end
end
describe Addressable::URI, "when parsed from " +

0 comments on commit 654cdf0

Please sign in to comment.