Skip to content

Commit

Permalink
deprecated: Nokogiri::HTML5.get
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Jun 21, 2021
1 parent e52ec9d commit 4ac9350
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -46,6 +46,11 @@ Future releases of Nokogiri may deprecate `HTML` methods or otherwise change thi
* [CRuby] Speed up (slightly) the compile time of packaged libraries `libiconv`, `libxml2`, and `libxslt` by using autoconf's `--disable-dependency-tracking` option. ("ruby" platform gem only.)


### Deprecated

* Deprecating Nokogumbo's `Nokogiri::HTML5.get`. This method will be removed in a future version of Nokogiri.


### Dependencies

* [CRuby] Upgrade mini_portile2 dependency from `~> 2.5.0` to `~> 2.6.1`. ("ruby" platform gem only.)
Expand Down
12 changes: 9 additions & 3 deletions lib/nokogiri/html5.rb
Expand Up @@ -250,6 +250,14 @@ def self.fragment(string, encoding = nil, **options)
# * :follow_limit => number of redirects which are followed
# * :basic_auth => [username, password]
def self.get(uri, options={})
warn("Nokogiri::HTML5.get is deprecated and will be removed in a future version of Nokogiri.",
uplevel: 1, category: :deprecated)
get_impl(uri, options)
end

private

def self.get_impl(uri, options={})
headers = options.clone
headers = {:follow_limit => headers} if Numeric === headers # deprecated
limit=headers[:follow_limit] ? headers.delete(:follow_limit).to_i : 10
Expand Down Expand Up @@ -292,14 +300,12 @@ def self.get(uri, options={})
when Net::HTTPRedirection
response.value if limit <= 1
location = URI.join(uri, response['location'])
get(location, options.merge(:follow_limit => limit-1))
get_impl(location, options.merge(:follow_limit => limit-1))
else
response.value
end
end

private

def self.read_and_encode(string, encoding)
# Read the string with the given encoding.
if string.respond_to?(:read)
Expand Down

0 comments on commit 4ac9350

Please sign in to comment.