Created
November 5, 2019 11:55
-
-
Save tit/58a48f304c190793a86d82f9438cca63 to your computer and use it in GitHub Desktop.
Case URI Regexp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
url_string = 'https://example.com/foo' | |
url_object = URI url_string | |
# false | |
puts case url_object | |
when %r{^https://example\.com} | |
true | |
else | |
false | |
end | |
# true | |
puts case String url_object | |
when %r{^https://example\.com} | |
true | |
else | |
false | |
end | |
# true | |
puts case url_string | |
when %r{^https://example\.com} | |
true | |
else | |
false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment