[ruby/uri] Restore constants like URI::REGEXP::PATTERN::IPV6ADDR

https://github.com/ruby/uri/commit/ee9a38701a
This commit is contained in:
Hiroshi SHIBATA 2024-11-13 12:01:06 +09:00 committed by git
parent e97dcf53a2
commit 1d6c986104
2 changed files with 13 additions and 0 deletions

View File

@ -536,4 +536,11 @@ module URI
end
end # class Parser
# Backward compatibility for URI::REGEXP::PATTERN::*
RFC2396_Parser.new.pattern.each_pair do |sym, str|
unless RFC2396_REGEXP::PATTERN.const_defined?(sym)
RFC2396_REGEXP::PATTERN.const_set(sym, str)
end
end
end # module URI

View File

@ -10,6 +10,10 @@ class URI::TestCommon < Test::Unit::TestCase
def teardown
end
class Foo
include URI::REGEXP::PATTERN
end
def test_fallback_constants
orig_verbose = $VERBOSE
$VERBOSE = nil
@ -19,6 +23,8 @@ class URI::TestCommon < Test::Unit::TestCase
assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI]
assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN
assert_equal URI::REGEXP, URI::RFC2396_REGEXP
assert_equal URI::REGEXP::PATTERN, URI::RFC2396_REGEXP::PATTERN
assert_equal Foo::IPV4ADDR, URI::RFC2396_REGEXP::PATTERN::IPV4ADDR
ensure
$VERBOSE = orig_verbose
end