diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 4e8210d..cf93fb1 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -45,6 +45,15 @@ def self.parser=(parser = RFC3986_PARSER) 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 = {} diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index aa9c689..bccdeaf 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -10,6 +10,15 @@ def setup 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)