Commit 616f89b4 authored by Boris Bügling's avatar Boris Bügling

Support relative redirects when validating URLs.

This fixes CocoaPods/Core#104
parent cbf504ca
......@@ -241,7 +241,14 @@ module Pod
end
if [301, 302, 303, 307, 308].include? resp.status_code
url = resp.headers['location'].first
location = resp.headers['location'].first
if location =~ /:\/\//
url = location
else
url = url + location
end
redirects += 1
else
break
......
......@@ -145,6 +145,18 @@ module Pod
@sut.validate
@sut.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/
end
it "supports relative redirects" do
WebMock::API.stub_request(:head, /redirect$/).to_return(
:status => 302,
:headers => { 'Location' => '/' })
WebMock::API.stub_request(:head, /redirect\/$/).to_return(
:status => 200 )
Specification.any_instance.stubs(:homepage).returns(
'http://banana-corp.local/redirect')
@sut.validate
@sut.results.length.should.equal 0
end
end
describe "Screenshot validation" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment