From 24a3714d62fa58eb0cf8c67253b1752ecb74bf56 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 12 Mar 2014 13:07:57 -0500 Subject: [PATCH] fix(api-redirect): update regex used for determining when to redirect With the old redirect, repositories with "png" in the name got redirected as well as images. --- lib/travis/web/api_redirect.rb | 2 +- spec/api_redirect_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/travis/web/api_redirect.rb b/lib/travis/web/api_redirect.rb index 04cca3b8..4f022af0 100644 --- a/lib/travis/web/api_redirect.rb +++ b/lib/travis/web/api_redirect.rb @@ -18,7 +18,7 @@ class Travis::Web::ApiRedirect < Sinatra::Base end end - get NotPublicImages.new(%r{^/([^/]+)/([^/]+).png}, %r{^/images/}) do + get NotPublicImages.new(%r{^/([^/]+)/([^/]+)\.png$}, %r{^/images/}) do redirect! end diff --git a/spec/api_redirect_spec.rb b/spec/api_redirect_spec.rb index bc8e2a9a..9993d086 100644 --- a/spec/api_redirect_spec.rb +++ b/spec/api_redirect_spec.rb @@ -10,4 +10,8 @@ describe Travis::Web::ApiRedirect do it 'redirects /:owner/:repo.png' do get('/foo/bar.png').should be_redirect end + + it 'does not redirect /owner/some-png-repo' do + get('/owner/some-png-repo').should_not be_redirect + end end