Only injects code into the first occurrence of <head> tags #62

Open
nathanhoel wants to merge 1 commits from nathanhoel/master into master
nathanhoel commented 2014-12-08 20:03:48 +00:00 (Migrated from github.com)

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 <head> with the injected code.

This fix simply makes sure we replace only the first occurrence of <head> as I believe was intended by the check found on line 73 of the body_processor.rb.

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 `<head>` with the injected code. This fix simply makes sure we replace only the first occurrence of `<head>` as I believe was intended by the check found on line 73 of the body_processor.rb.
nathanhoel commented 2015-12-15 19:34:39 +00:00 (Migrated from github.com)

If I rebased this would someone be willing to merge this PR?

If I rebased this would someone be willing to merge this PR?
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin nathanhoel/master:nathanhoel/master
git checkout nathanhoel/master
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: github-migration/rack-livereload#62
No description provided.