johnbintz/rack-livereload — pull request #62 by nathanhoel (2014-12-08 20:03:48+00:00)
Title: Only injects code into the first occurrence of <head> tags

This partially addresses issue #60

I think the idea was that https://github.com/johnbintz/rack-livereload/blob/master/lib/rack/livereload/body_processor.rb#L73 would prevent this issue from occurring.
However RACK can pass the entire document as a single line. So when entering this section of code the @livereload_added would still be false and then it would proceed to replace all occurrences of the text

with the injected code.

This fix simply makes sure we replace only the first occurrence of

as I believe was intended by the check found on line 73 of the body_processor.rb.