diff --git a/lib/microformats2/collection.rb b/lib/microformats2/collection.rb index 09d106a..875acc4 100644 --- a/lib/microformats2/collection.rb +++ b/lib/microformats2/collection.rb @@ -110,7 +110,7 @@ module Microformats2 end def absolutize(href) - if URI.parse(href).absolute? + if URI.parse(href).absolute? || @base.nil? href else URI.join(@base, href).to_s diff --git a/spec/lib/microformats2/collection_spec.rb b/spec/lib/microformats2/collection_spec.rb index dfca7f3..9aa62af 100644 --- a/spec/lib/microformats2/collection_spec.rb +++ b/spec/lib/microformats2/collection_spec.rb @@ -190,6 +190,17 @@ describe Microformats2::Collection do end end end + + describe "rels-that-drop-the-base.html" do + before do + html = "spec/support/lib/microformats2/rels-that-drop-the-base.html" + @collection = Microformats2.parse(html) + end + + it "keeps the relative path" do + @collection.to_hash[:rels]["stylesheet"].should eq([ "/path/to/stylesheet.css" ]) + end + end end diff --git a/spec/support/lib/microformats2/rels-that-drop-the-base.html b/spec/support/lib/microformats2/rels-that-drop-the-base.html new file mode 100644 index 0000000..56ed5f4 --- /dev/null +++ b/spec/support/lib/microformats2/rels-that-drop-the-base.html @@ -0,0 +1,11 @@ + + + +Rels without Base Test + + + +
  • Jeremy Keith
  • +
  • Tantek Çelik
  • + +