diff --git a/lib/middleware/request_tracker.rb b/lib/middleware/request_tracker.rb index 5f3a1f74583..41ad8a60b41 100644 --- a/lib/middleware/request_tracker.rb +++ b/lib/middleware/request_tracker.rb @@ -118,7 +118,7 @@ class Middleware::RequestTracker if h[:is_crawler] user_agent = env['HTTP_USER_AGENT'] - if user_agent.encoding != Encoding::UTF_8 + if user_agent && (user_agent.encoding != Encoding::UTF_8) user_agent = user_agent.encode("utf-8") user_agent.scrub! end diff --git a/spec/components/hijack_spec.rb b/spec/components/hijack_spec.rb index a0ef15e97f8..7e30a5439e1 100644 --- a/spec/components/hijack_spec.rb +++ b/spec/components/hijack_spec.rb @@ -65,7 +65,6 @@ describe Hijack do expect(@calls).to eq(1) expect(@status).to eq(201) - expect(@status).to be > 0 end end