mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
[ruby/uri] Fallback missing constants with RFC3986_PARSER
(https://github.com/ruby/uri/pull/113)
* Fallback missing constants with RFC3986_PARSER
* raise missing constant
* Update test/uri/test_common.rb
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Update lib/uri/common.rb
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Update lib/uri/common.rb
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
---------
c2fdec079a
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
This commit is contained in:
parent
24d46a6781
commit
267da552a1
2 changed files with 18 additions and 0 deletions
|
@ -45,6 +45,15 @@ module URI
|
|||
end
|
||||
self.parser = RFC3986_PARSER
|
||||
|
||||
def self.const_missing(const)
|
||||
if value = RFC2396_PARSER.regexp[const]
|
||||
warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
|
||||
value
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
module Util # :nodoc:
|
||||
def make_components_hash(klass, array_hash)
|
||||
tmp = {}
|
||||
|
|
|
@ -10,6 +10,15 @@ class URI::TestCommon < Test::Unit::TestCase
|
|||
def teardown
|
||||
end
|
||||
|
||||
def test_fallback_constants
|
||||
orig_verbose = $VERBOSE
|
||||
$VERBOSE = nil
|
||||
assert URI::ABS_URI
|
||||
assert_raise(NameError) { URI::FOO }
|
||||
ensure
|
||||
$VERBOSE = orig_verbose
|
||||
end
|
||||
|
||||
def test_parser_switch
|
||||
assert_equal(URI::Parser, URI::RFC3986_Parser)
|
||||
refute defined?(URI::REGEXP)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue