Skip to content

Commit

Permalink
Merge pull request #662 from sparklemotion/flavorjones-ruby-34-warnings
Browse files Browse the repository at this point in the history
quash Ruby 3.4 URI::Parser warnings
  • Loading branch information
flavorjones authored Jan 2, 2025
2 parents e9bc524 + be2de52 commit e564d56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## next / unreleased

* Quash frozen string warnings in Ruby 3.4. (#661) @simpl1g
* Quash URI::Parser warnings in Ruby 3.4. (#662) @flavorjones


## 2.12.2 / 2023-10-02
Expand Down
30 changes: 14 additions & 16 deletions lib/mechanize/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,27 @@ def self.detect_charset(src)
end

def self.uri_escape str, unsafe = nil
@parser ||= begin
URI::Parser.new
rescue NameError
URI
end

if URI == @parser then
if URI == parser then
unsafe ||= URI::UNSAFE
else
unsafe ||= @parser.regexp[:UNSAFE]
unsafe ||= parser.regexp[:UNSAFE]
end

@parser.escape str, unsafe
parser.escape str, unsafe
end

def self.uri_unescape str
@parser ||= begin
URI::Parser.new
rescue NameError
URI
end

@parser.unescape str
parser.unescape str
end

def self.parser
@parser ||=
if defined?(URI::RFC2396_PARSER)
URI::RFC2396_PARSER
elsif defined?(URI::Parser)
URI::Parser.new
else
URI
end
end
end

0 comments on commit e564d56

Please sign in to comment.