Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c2b646

Browse files
committed
Make URI::regexp schemes case sensitive (#38)
1 parent 6f44d3d commit 0c2b646

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)