[ruby/uri] Make URI::regexp schemes case sensitive

(https://github.com/ruby/uri/pull/38)

0c2b6468fa
This commit is contained in:
Nobuyoshi Nakada 2025-07-08 19:35:06 +09:00 committed by git
parent c47a92b63d
commit f1764623db
2 changed files with 9 additions and 1 deletions

View file

@ -263,7 +263,7 @@ module URI
unless schemes
@regexp[:ABS_URI_REF]
else
/(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
/(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x
end
end

View file

@ -113,4 +113,12 @@ class URI::TestParser < Test::Unit::TestCase
end
end
end
def test_rfc2822_make_regexp
parser = URI::RFC2396_Parser.new
regexp = parser.make_regexp("HTTP")
assert_match(regexp, "HTTP://EXAMPLE.COM/")
assert_match(regexp, "http://example.com/")
refute_match(regexp, "https://example.com/")
end
end