Don't redirect to api if we want something from images dir
This commit is contained in:
parent
06d90dbc9b
commit
88c5bae9fc
|
@ -4,7 +4,21 @@ class Travis::Web::ApiRedirect < Sinatra::Base
|
|||
disable :protection, :static
|
||||
set api_endpoint: 'https://api.travis-ci.org'
|
||||
|
||||
get '/:owner_name/:name.png' do
|
||||
class NotPublicImages
|
||||
Match = Struct.new(:captures)
|
||||
|
||||
def initialize(pattern, except)
|
||||
@except = except
|
||||
@pattern = pattern
|
||||
@captures = Match.new([])
|
||||
end
|
||||
|
||||
def match(str)
|
||||
@captures if str =~ @pattern && str !~ @except
|
||||
end
|
||||
end
|
||||
|
||||
get NotPublicImages.new(%r{^/(\w+)/(\w+).png}, %r{^/images/}) do
|
||||
redirect!
|
||||
end
|
||||
|
||||
|
@ -14,6 +28,10 @@ class Travis::Web::ApiRedirect < Sinatra::Base
|
|||
|
||||
private
|
||||
|
||||
def public_image?
|
||||
params[:owner_name] == 'images'
|
||||
end
|
||||
|
||||
def redirect!(path = nil)
|
||||
path = File.join(settings.api_endpoint, path || request.fullpath)
|
||||
redirect(path, 301)
|
||||
|
|
Loading…
Reference in New Issue
Block a user