Sha256: f0e2b7a81fac8b8aec86145004e52a9d13d489607fe49fa128ef1eaedf1bfa87

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

require 'hashie'

module Html2rss
  module Utils
    ##
    # A Hash with indifferent access, build with {https://github.com/intridea/hashie Hashie}.
    class IndifferentAccessHash < Hash
      include Hashie::Extensions::MergeInitializer
      include Hashie::Extensions::IndifferentAccess
    end

    def self.build_absolute_url_from_relative(url, channel_url)
      url = URI(url) if url.is_a?(String)

      return url if url.absolute?

      URI(channel_url).tap do |uri|
        uri.path = url.path.to_s.start_with?('/') ? url.path : "/#{url.path}"
        uri.query = url.query
        uri.fragment = url.fragment if url.fragment
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
html2rss-0.4.1 lib/html2rss/utils.rb