FIX: Escape URL before attempting to resolve it.
This commit is contained in:
parent
089a1bd3be
commit
b534778f46
|
@ -12,7 +12,7 @@ class FinalDestination
|
|||
def initialize(url, opts=nil)
|
||||
@uri =
|
||||
begin
|
||||
URI(url) if url
|
||||
URI(URI.escape(url)) if url
|
||||
rescue URI::InvalidURIError
|
||||
end
|
||||
|
||||
|
|
|
@ -60,6 +60,14 @@ describe FinalDestination do
|
|||
stub_request(:head, "https://eviltrout.com").to_return(doc_response)
|
||||
end
|
||||
|
||||
it "escapes url" do
|
||||
url = 'https://eviltrout.com?s=180&d=mm&r=g'
|
||||
escaped_url = URI.escape(url)
|
||||
stub_request(:head, escaped_url).to_return(doc_response)
|
||||
|
||||
expect(fd(url).resolve.to_s).to eq(escaped_url)
|
||||
end
|
||||
|
||||
it "returns the final url" do
|
||||
final = FinalDestination.new('https://eviltrout.com', opts)
|
||||
expect(final.resolve.to_s).to eq('https://eviltrout.com')
|
||||
|
|
Loading…
Reference in New Issue