Skip to content

Commit 799bceb

Browse files
Use ruby 3.1's uri's register_scheme if available
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.
1 parent 5ed6181 commit 799bceb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/uri/scp.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SCP < Generic
88
:scheme,
99
:userinfo,
1010
:host, :port, :path,
11-
:query
11+
:query
1212
].freeze
1313

1414
attr_reader :options
@@ -31,5 +31,9 @@ def initialize(*args)
3131
end
3232
end
3333

34-
@@schemes['SCP'] = SCP
35-
end
34+
if respond_to? :register_scheme
35+
register_scheme "SCP", SCP
36+
else
37+
@@schemes["SCP"] = SCP
38+
end
39+
end

0 commit comments

Comments
 (0)