Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ test/tmp
test/version_tmp
tmp
.DS_Store
.idea
5 changes: 2 additions & 3 deletions lib/rack/tracker/google_tag_manager/google_tag_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ def inject(response)
# Sub! is enough, in well formed html there's only one head or body tag.
# Block syntax need to be used, otherwise backslashes in input will mess the output.
# @see http://stackoverflow.com/a/4149087/518204 and https://github.com/railslove/rack-tracker/issues/50
response.sub! %r{<head.*>} do |m|
response_dup = response.sub %r{<head.*>} do |m|
m.to_s << self.render_head
end
response.sub! %r{<body.*?>} do |m|
response_dup.sub %r{<body.*?>} do |m|
m.to_s << self.render_body
end
response
end

def container
Expand Down
3 changes: 1 addition & 2 deletions lib/rack/tracker/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ def inject(response)
# Sub! is enough, in well formed html there's only one head or body tag.
# Block syntax need to be used, otherwise backslashes in input will mess the output.
# @see http://stackoverflow.com/a/4149087/518204 and https://github.com/railslove/rack-tracker/issues/50
response.sub! %r{</#{self.position}>} do |m|
response.sub %r{</#{self.position}>} do |m|
self.render << m.to_s
end
response
end

def write_event(event)
Expand Down