Two scripts added when response body includes both `<head>` and `<header>` tags
stevejmp opened this issue · comments
stevejmp commented
Expected
One script added to the response body, when it includes both <head>
and <header>
tags.
Actual
Two scripts added to the response body.
Steps to Reproduce
- Run a task using ring-refresh in a project
- Return a response body with both
<head>
and<header>
tags<html> <head> <title>Title</title> </head> <body> <header>This is a header</header> </body> </html>
- Observe the script being added to the response body twice, in the
<head>
and<header>
tags
Versions
Ring-Refresh 0.1.2 (lein-ring 0.12.6 -> lein-server 0.5.0 -> ring-refresh 0.1.2)
Clojure 1.11.0
Java 11.0.14
Leiningen 2.9.8
More Info
The regex in refresh/add-script is a bit greedy: #"<head\s*[^>]*>"
Fix: Replacing it with @"<head(?!er)\s*[^\/>]*>"
seems to accommodate the different scenarios.
PR incoming.