Normalize u-* property values for implied properties
This commit is contained in:
parent
249fc1ef74
commit
0eb04480f5
6 changed files with 73 additions and 4 deletions
|
@ -41,7 +41,7 @@ module Microformats2
|
|||
def parse_implied_properties
|
||||
ip = []
|
||||
ip << ImpliedProperty::Name.new(@element).parse unless property_present?(:name)
|
||||
ip << ImpliedProperty::Url.new(@element).parse unless property_present?(:url)
|
||||
ip << ImpliedProperty::Url.new(@element, @base).parse unless property_present?(:url)
|
||||
ip << ImpliedProperty::Photo.new(@element).parse unless property_present?(:photo)
|
||||
ip.compact.each do |property|
|
||||
save_property_name(property.method_name)
|
||||
|
|
|
@ -2,8 +2,9 @@ module Microformats2
|
|||
module ImpliedProperty
|
||||
class Foundation
|
||||
|
||||
def initialize(element)
|
||||
def initialize(element, base=nil)
|
||||
@element = element
|
||||
@base = base
|
||||
end
|
||||
|
||||
def parse
|
||||
|
|
|
@ -6,6 +6,22 @@ module Microformats2
|
|||
"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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue