diff options
author | Hiroshi SHIBATA <[email protected]> | 2024-11-13 12:01:06 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-11-14 02:20:04 +0000 |
commit | 1d6c986104afa77f5874cd2f8441682e59b2097a (patch) | |
tree | cb472ae9646d422267ef5fdde669adaed2ce831a | |
parent | e97dcf53a2daea113eed4823dced90998d172684 (diff) |
[ruby/uri] Restore constants like URI::REGEXP::PATTERN::IPV6ADDR
https://github.com/ruby/uri/commit/ee9a38701a
-rw-r--r-- | lib/uri/rfc2396_parser.rb | 7 | ||||
-rw-r--r-- | test/uri/test_common.rb | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index a56ca34267..c112b1b368 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -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 diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 176efb80b9..b1e3b2be66 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -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 |