Created
January 1, 2012 17:52
-
-
Save bcardarella/1547904 to your computer and use it in GitHub Desktop.
Demonstrate URI.extract bug
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
require 'uri' | |
require 'test/unit' | |
class UriExtractTest < Test::Unit::TestCase | |
def test_extract | |
expected = 'http://example.com' | |
sample = %{'#{expected}'} | |
result = URI.extract(sample, ['http']).first | |
assert_equal expected, result | |
end | |
def test_extract_with_trailing_slash | |
expected = 'http://example.com/' | |
sample = %{'#{expected}'} | |
result = URI.extract(sample, ['http']).first | |
assert_equal expected, result | |
end | |
def test_extract_with_trailing_slash_and_double_quote | |
expected = 'http://example.com/' | |
sample = %{"#{expected}"} | |
result = URI.extract(sample, ['http']).first | |
assert_equal expected, result | |
end | |
def test_extract_with_path | |
expected = 'http://example.com/path' | |
sample = %{'#{expected}'} | |
result = URI.extract(sample, ['http']).first | |
assert_equal expected, result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment