Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/uri/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def self.parser=(parser = RFC3986_PARSER)
end
self.parser = RFC3986_PARSER

def self.const_missing(const)
if RFC2396_PARSER.regexp[const]
warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
RFC2396_PARSER.regexp[const]
Comment thread
hsbt marked this conversation as resolved.
Outdated
else
raise NameError, "uninitialized constant URI::#{const}"
Comment thread
hsbt marked this conversation as resolved.
Outdated
end
end

module Util # :nodoc:
def make_components_hash(klass, array_hash)
tmp = {}
Expand Down
8 changes: 8 additions & 0 deletions test/uri/test_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def setup
def teardown
end

def test_fallback_constants
orig_verbose = $VERBOSE
$VERBOSE = nil
assert URI::ABS_URI
assert_raise(NameError) { URI::FOO }
$VERBOSE = orig_verbose
Comment thread
hsbt marked this conversation as resolved.
end

def test_parser_switch
assert_equal(URI::Parser, URI::RFC3986_Parser)
refute defined?(URI::REGEXP)
Expand Down