Skip to content

Commit

Permalink
Merge pull request #637 from rollbar/fix-split-host
Browse files Browse the repository at this point in the history
nil guards in request_data_extractor
  • Loading branch information
rokob authored Sep 18, 2017
2 parents 7077723 + cb537da commit 7d51701
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rollbar/request_data_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ def rollbar_url(env)
forwarded_proto = env['HTTP_X_FORWARDED_PROTO'] || env['rack.url_scheme'] || ''
scheme = forwarded_proto.split(',').first

forwarded_host = env['HTTP_X_FORWARDED_HOST'] || env['HTTP_HOST'] || env['SERVER_NAME']
host = forwarded_host && forwarded_host.split(',').first.strip
host = env['HTTP_X_FORWARDED_HOST'] || env['HTTP_HOST'] || env['SERVER_NAME'] || ''
host = host.split(',').first.strip unless host.empty?

path = env['ORIGINAL_FULLPATH'] || env['REQUEST_URI']
unless path.nil? || path.empty?
path = '/' + path.to_s if path.to_s.slice(0, 1) != '/'
end

port = env['HTTP_X_FORWARDED_PORT']
if port && !(scheme.downcase == 'http' && port.to_i == 80) && \
!(scheme.downcase == 'https' && port.to_i == 443) && \
if port && !(!scheme.nil? && scheme.downcase == 'http' && port.to_i == 80) && \
!(!scheme.nil? && scheme.downcase == 'https' && port.to_i == 443) && \
!(host.include? ':')
host = host + ':' + port
end
Expand Down

0 comments on commit 7d51701

Please sign in to comment.