diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-07-28 12:00:33 +0200 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-05-12 18:19:17 +0900 |
commit | 40ca208a6db8d3a53cc016caab2aa8301bafdac2 (patch) | |
tree | 88e7b92860030e397fc9539778566ba77748c6ad /lib/uri/common.rb | |
parent | fbebfe1697938a684f460cd28af36cf1f056513c (diff) |
[ruby/uri] Improve URI.register_scheme tests and automatically upcase the given scheme
* Also add docs and mention current limitations.
* For reference, https://stackoverflow.com/a/3641782/388803 mentions the
valid characters in schemes.
https://github.com/ruby/uri/commit/4346daac75
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r-- | lib/uri/common.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb index a6d08aa26f..ca38bec7ec 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -68,8 +68,13 @@ module URI end private_constant :Schemes + # + # Register the given +klass+ to be instantiated when parsing URLs with the given +scheme+. + # Note that currently only schemes which after .upcase are valid constant names + # can be registered (no -/+/. allowed). + # def self.register_scheme(scheme, klass) - Schemes.const_set(scheme, klass) + Schemes.const_set(scheme.to_s.upcase, klass) end # Returns a Hash of the defined schemes. |