lib/html2rss/utils.rb in html2rss-0.12.0 vs lib/html2rss/utils.rb in html2rss-0.13.0

- old
+ new

@@ -29,16 +29,16 @@ end ## # Removes any space, parses and normalizes the given url. # @param url [String] - # @return [String, nil] sanitized and normalized URL, or nil if input is empty + # @return [Addressable::URI, nil] normalized URL, or nil if input is empty def self.sanitize_url(url) url = url.to_s.gsub(/\s+/, ' ').strip return if url.empty? - Addressable::URI.parse(url).normalize.to_s + Addressable::URI.parse(url).normalize end ## # Allows override of time zone locally inside supplied block; resets previous time zone when done. # @@ -69,21 +69,16 @@ nicer_path.any? ? "#{host}: #{nicer_path.map(&:capitalize).join(' ')}" : host end ## # @param url [String, Addressable::URI] - # @param convert_json_to_xml [true, false] Should JSON be converted to XML # @param headers [Hash] additional HTTP request headers to use for the request - # @return [String] body of the HTTP response - def self.request_body_from_url(url, convert_json_to_xml: false, headers: {}) - response = Faraday.new(url:, headers:) do |faraday| + # @return [Faraday::Response] body of the HTTP response + def self.request_url(url, headers: {}) + Faraday.new(url:, headers:) do |faraday| faraday.use Faraday::FollowRedirects::Middleware faraday.adapter Faraday.default_adapter end.get - - body = response.body - - convert_json_to_xml ? ObjectToXmlConverter.new(JSON.parse(body)).call : body end ## # Parses the given String and builds a Regexp out of it. #