Skip to content

Commit

Permalink
Add tweaks for js/middleware.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon de Andres committed Feb 10, 2016
1 parent b1756a1 commit de709b7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/rollbar/js/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def add_js(response)

return nil unless body

head_close = find_end_of_head_open(body)
head_open_end = find_end_of_head_open(body)
return nil unless head_close

if head_close
body = body[0..head_close] <<
if head_open_end
body = body[0..head_open_end] <<
config_js_tag <<
snippet_js_tag <<
body[head_close..-1]
Expand All @@ -101,14 +101,6 @@ def close_old_response(response)
response.close if response.respond_to?(:close)
end

def calculate_content_length(source)
if source.respond_to?(:bytesize)
source.bytesize
else
source.length
end
end

def config_js_tag
script_tag("var _rollbarConfig = #{config[:options].to_json};")
end
Expand All @@ -118,7 +110,7 @@ def snippet_js_tag
end

def js_snippet
@js_snippet ||= SNIPPET
SNIPPET
end

def script_tag(content)
Expand Down

0 comments on commit de709b7

Please sign in to comment.