diff --git a/lib/travis/web/app/mobile_redirect.rb b/lib/travis/web/app/mobile_redirect.rb index 5593b9e5..f2ecaaf7 100644 --- a/lib/travis/web/app/mobile_redirect.rb +++ b/lib/travis/web/app/mobile_redirect.rb @@ -2,7 +2,7 @@ class Travis::Web::App::MobileRedirect < Struct.new(:app) def call(env) request = Rack::Request.new env - if request.params['mobile'] || env['HTTP_AGENT'] =~ /Mobile|webOS/ + if request.params['mobile'] || request.user_agent.to_s =~ /Mobile|webOS/ location = 'https://secure.travis-ci.org' + request.fullpath [301, { 'Content-Type' => 'text/plain', 'Location' => location }, []] else diff --git a/spec/mobile_redirect_spec.rb b/spec/mobile_redirect_spec.rb index 03871d53..490cfae4 100644 --- a/spec/mobile_redirect_spec.rb +++ b/spec/mobile_redirect_spec.rb @@ -6,7 +6,7 @@ describe Travis::Web::App::MobileRedirect do let(:agent) { 'blah blah Mobile blablah' } it 'redirects to secure.travis-ci.org' do - get('/foo/bar?baz', {}, 'HTTP_AGENT' => agent).should be_redirect + get('/foo/bar?baz', {}, 'HTTP_USER_AGENT' => agent).should be_redirect last_response.headers['Location'].should == 'https://secure.travis-ci.org/foo/bar?baz' end end