Skip to content

Commit

Permalink
Restore constants like URI::REGEXP::PATTERN::IPV6ADDR
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Nov 13, 2024
1 parent c59a977 commit ee9a387
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/uri/rfc2396_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,11 @@ def convert_to_uri(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
6 changes: 6 additions & 0 deletions test/uri/test_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def setup
def teardown
end

class Foo
include URI::REGEXP::PATTERN
end

def test_fallback_constants
orig_verbose = $VERBOSE
$VERBOSE = nil
Expand All @@ -19,6 +23,8 @@ def test_fallback_constants
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
Expand Down

0 comments on commit ee9a387

Please sign in to comment.