lib/micro_micro/document.rb in micromicro-1.0.0 vs lib/micro_micro/document.rb in micromicro-1.1.0

- old
+ new

@@ -63,11 +63,11 @@ @relationships ||= Collections::RelationshipsCollection.new(Relationship.relationships_from(document)) end # Return the parsed document as a Hash. # - # @see http://microformats.org/wiki/microformats2-parsing#parse_a_document_for_microformats + # @see https://microformats.org/wiki/microformats2-parsing#parse_a_document_for_microformats # # @return [Hash{Symbol => Array, Hash}] def to_h { items: items.to_a, @@ -89,12 +89,12 @@ # @return [Array<String>] def self.ignored_node_names %w[script style template] end - # @see http://microformats.org/wiki/microformats2-parsing#parse_an_element_for_properties - # @see http://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties + # @see https://microformats.org/wiki/microformats2-parsing#parse_an_element_for_properties + # @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties # # @param context [Nokogiri::HTML::Document, Nokogiri::XML::NodeSet, Nokogiri::XML::Element] # @yield [context] # @return [String] def self.text_content_from(context) @@ -120,29 +120,29 @@ end def resolve_relative_urls HTML_URL_ATTRIBUTES_MAP.each do |attribute, names| document.xpath(*names.map { |name| "//#{name}[@#{attribute}]" }).each do |node| - node[attribute] = Absolutely.to_abs(base: resolved_base_url, relative: node[attribute].strip) + node[attribute] = Addressable::URI.join(resolved_base_url, node[attribute].strip).normalize.to_s end end HTML_IMAGE_CANDIDATE_STRINGS_ATTRIBUTES_MAP.each do |attribute, names| document.xpath(*names.map { |name| "//#{name}[@#{attribute}]" }).each do |node| candidates = node[attribute].split(',').map(&:strip).map { |candidate| candidate.match(/^(?<url>.+?)(?<descriptor>\s+.+)?$/) } - node[attribute] = candidates.map { |candidate| "#{Absolutely.to_abs(base: resolved_base_url, relative: candidate[:url])}#{candidate[:descriptor]}" }.join(', ') + node[attribute] = candidates.map { |candidate| "#{Addressable::URI.join(resolved_base_url, candidate[:url]).normalize}#{candidate[:descriptor]}" }.join(', ') end end self end # @return [String] def resolved_base_url @resolved_base_url ||= begin if base_element - Absolutely.to_abs(base: base_url, relative: base_element['href'].strip) + Addressable::URI.join(base_url, base_element['href'].strip).normalize.to_s else base_url end end end