Resolve relative URLs (bugfix)

When the <base> tag is used, the @base wasn't handed down all the way to URLs
and photos, this patch fixes this problem.

In addition to that it also makes it possible to handle u-url on <input> tags.
This commit is contained in:
Jeena 2015-08-21 21:17:54 +02:00
parent 1e9e65cf9e
commit 6c90f01ae7
4 changed files with 9 additions and 4 deletions

View file

@ -40,9 +40,9 @@ module Microformats2
def parse_implied_properties
ip = []
ip << ImpliedProperty::Name.new(@element).parse unless property_present?(:name)
ip << ImpliedProperty::Name.new(@element, @base).parse unless property_present?(:name)
ip << ImpliedProperty::Url.new(@element, @base).parse unless property_present?(:url)
ip << ImpliedProperty::Photo.new(@element).parse unless property_present?(:photo)
ip << ImpliedProperty::Photo.new(@element, @base).parse unless property_present?(:photo)
ip.compact.each do |property|
save_property_name(property.method_name)
define_method(property.method_name)

View file

@ -6,6 +6,10 @@ module Microformats2
"photo"
end
def to_s
@to_s = Microformats2::AbsoluteUri.new(@base, super.to_s).absolutize
end
protected
def name_map

View file

@ -25,7 +25,7 @@ module Microformats2
end
def formats
@formats ||= format_classes.length >=1 ? FormatParser.parse(@element) : []
@formats ||= format_classes.length >=1 ? FormatParser.parse(@element, @base) : []
end
def to_hash

View file

@ -15,7 +15,8 @@ module Microformats2
"img" => "src",
"object" => "data",
"abbr" => "title",
"data" => "value" }
"data" => "value",
"input" => "value" }
end
end
end