Skip to content

Commit f176462

Browse files
nobumatzbot
authored andcommitted
[ruby/uri] Make URI::regexp schemes case sensitive
(ruby/uri#38) ruby/uri@0c2b6468fa
1 parent c47a92b commit f176462

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/uri/rfc2396_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def make_regexp(schemes = nil)
263263
unless schemes
264264
@regexp[:ABS_URI_REF]
265265
else
266-
/(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
266+
/(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x
267267
end
268268
end
269269

test/uri/test_parser.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,12 @@ def test_rfc3986_port_check
113113
end
114114
end
115115
end
116+
117+
def test_rfc2822_make_regexp
118+
parser = URI::RFC2396_Parser.new
119+
regexp = parser.make_regexp("HTTP")
120+
assert_match(regexp, "HTTP://EXAMPLE.COM/")
121+
assert_match(regexp, "http://example.com/")
122+
refute_match(regexp, "https://example.com/")
123+
end
116124
end

0 commit comments

Comments
 (0)