Permalink
Browse files

Added https support to heuristic_parse

  • Loading branch information...
1 parent 354f223 commit 49e2f1f799d7481a705d416441b1dc1f442e0442 @zquestz zquestz committed Apr 11, 2011
Showing with 31 additions and 0 deletions.
  1. +2 −0 lib/addressable/uri.rb
  2. +29 −0 spec/addressable/uri_spec.rb
View
@@ -153,6 +153,8 @@ def self.heuristic_parse(uri, hints={})
case uri
when /^http:\/+/
uri.gsub!(/^http:\/+/, "http://")
+ when /^https:\/+/
+ uri.gsub!(/^https:\/+/, "https://")
when /^feed:\/+http:\/+/
uri.gsub!(/^feed:\/+http:\/+/, "feed:http://")
when /^feed:\/+/
@@ -4354,6 +4354,17 @@ def to_str
end
end
+describe Addressable::URI, "when given the input " +
+ "'https://example.com/'" do
+ before do
+ @input = "https://example.com/"
+ end
+
+ it "should heuristically parse to 'https://example.com/'" do
+ @uri = Addressable::URI.heuristic_parse(@input)
+ @uri.to_s.should == "https://example.com/"
+ end
+end
describe Addressable::URI, "when given the input " +
"'http:example.com/'" do
@@ -4374,6 +4385,24 @@ def to_str
end
describe Addressable::URI, "when given the input " +
+ "'https:example.com/'" do
+ before do
+ @input = "https:example.com/"
+ end
+
+ it "should heuristically parse to 'https://example.com/'" do
+ @uri = Addressable::URI.heuristic_parse(@input)
+ @uri.to_s.should == "https://example.com/"
+ end
+
+ it "should heuristically parse to 'https://example.com/' " +
+ "even with a scheme hint of 'ftp'" do
+ @uri = Addressable::URI.heuristic_parse(@input, {:scheme => 'ftp'})
+ @uri.to_s.should == "https://example.com/"
+ end
+end
+
+describe Addressable::URI, "when given the input " +
"'http://example.com/example.com/'" do
before do
@input = "http://example.com/example.com/"

0 comments on commit 49e2f1f

Please sign in to comment.