Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created January 1, 2012 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcardarella/1547904 to your computer and use it in GitHub Desktop.
Save bcardarella/1547904 to your computer and use it in GitHub Desktop.
Demonstrate URI.extract bug
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