Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quash Ruby 3.4 URI::Parser warnings #662

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading