Redirect /:owner/:name/builds.json to a proper api endpoint
This commit is contained in:
parent
d94b001e81
commit
de38b3d297
|
@ -24,6 +24,10 @@ class Travis::Web::ApiRedirect < Sinatra::Base
|
||||||
redirect!
|
redirect!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get '/:owner_name/:name/builds.json' do
|
||||||
|
redirect! "/repos#{request.fullpath}"
|
||||||
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
redirect! if catch_all? and api_call?
|
redirect! if catch_all? and api_call?
|
||||||
end
|
end
|
||||||
|
@ -40,8 +44,8 @@ class Travis::Web::ApiRedirect < Sinatra::Base
|
||||||
settings.api_types.include? preferred
|
settings.api_types.include? preferred
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect!
|
def redirect!(path = nil)
|
||||||
path = File.join(settings.api_endpoint, request.fullpath)
|
path = File.join(settings.api_endpoint, path || request.fullpath)
|
||||||
redirect(path, 301)
|
redirect(path, 301)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,4 +30,10 @@ describe Travis::Web::ApiRedirect do
|
||||||
it 'does not redirect asset requests' do
|
it 'does not redirect asset requests' do
|
||||||
get('/version').should_not be_redirect
|
get('/version').should_not be_redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'redirects /:owner_name/:name/builds.json' do
|
||||||
|
response = get('/foo/bar/builds.json')
|
||||||
|
response.should be_redirect
|
||||||
|
response.headers['Location'].should == 'https://api.travis-ci.org/repos/foo/bar/builds.json'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user