Skip to content

Commit

Permalink
Use ruby 3.1's uri's register_scheme if available
Browse files Browse the repository at this point in the history
Ruby 3.1 adopted uri 0.11.0. That version changes how schemes can be registered. There is now a register_scheme method.

ruby/uri#26 as part of https://github.com/ruby/uri/releases/tag/v0.11.0

This commit supports both ways and works with the new method if available. The old way errors out when run  on uri>=0.11.0/ruby>=3.1.
  • Loading branch information
rtokarek-fastly committed Jun 21, 2024
1 parent 5ed6181 commit 799bceb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/uri/scp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SCP < Generic
:scheme,
:userinfo,
:host, :port, :path,
:query
:query
].freeze

attr_reader :options
Expand All @@ -31,5 +31,9 @@ def initialize(*args)
end
end

@@schemes['SCP'] = SCP
end
if respond_to? :register_scheme
register_scheme "SCP", SCP
else
@@schemes["SCP"] = SCP
end
end

0 comments on commit 799bceb

Please sign in to comment.