-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing <script>s on test page #109
Conversation
4ca171f
to
fdc5c86
Compare
var jsesc = require('jsesc'); | ||
|
||
module.exports = (value) => jsesc( | ||
value.replace(/[\r\n]{1,2}/g, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the .replace
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original idea was to use jsesc(value, { wrap: true })
so it returns a string literal including the quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs .replace(/<\/script/g, '<\\/script>')
since the output is placed inside a <script>
in HTML.
My earlier question remains, though: why .replace(/[\r\n]{1,2}/g, ')'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct, problem is that i thought jsesc was doing weird escaping but it was handlebars. I will push new commits later today.
fdc5c86
to
a72a9bf
Compare
Updated :) Let me know if it's okay :) |
@@ -29,7 +29,31 @@ | |||
</footer> | |||
|
|||
{{#if benchmark}} | |||
<script src="/test.js"></script> | |||
<script src="/test.js"></script> <script src="/test.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just need this once, right?
I think we’re almost there! Left some comments. |
{ | ||
wrap: true | ||
} | ||
).replace(/<\/script/g, '<\\/script>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s update jsesc to v1.1.0 and use escapeEtago: true
instead of doing the .replace
ourselves. 👍
a72a9bf
to
dcb1e7f
Compare
My tests didn't work so i didn't see some issues. But now they are fixed . I updated everything said above :) hopefully I finally got it right :p |
LGTM! Thanks, @wardpeet! |
Code with comments break, not sure how to fix this
should fix #85