lib/microformats2/implied_property/url.rb in microformats2-2.0.0.pre5 vs lib/microformats2/implied_property/url.rb in microformats2-2.0.0

- old
+ new

@@ -4,9 +4,25 @@ def method_name "url" end + def to_s + @to_s = absolutize(super.to_s) if super.to_s != "" + end + + # TODO: make dry, repeated in Collection + def absolutize(href) + uri = URI.parse(href) + + if @base && !uri.absolute? + uri = URI.join(@base, href) + end + + uri.normalize! + uri.to_s + end + protected def name_map { "a" => "href" } end