-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
fix(index): escape double quotes correctly (options.interpolate
)
#154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,11 @@ describe("loader", function() { | |
'module.exports = "<!-- comment --><h3 customattr=\\"\\">#{number} {customer}</h3><p>{title}</p><!-- comment --><img src=\" + require("./image.png") + \" />";' | ||
); | ||
}); | ||
it("should preserve escaped quotes", function() { | ||
loader.call({}, '<script>{"json": "with \\"quotes\\" in value"}</script>').should.be.eql( | ||
'module.exports = "<script>{\\\"json\\\": \\\"with \\\\\\\"quotes\\\\\\\" in value\\\"}</script>";' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only occurs for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Michael, |
||
); | ||
}) | ||
|
||
it("should preserve comments and white spaces when minimizing (via webpack config property)", function() { | ||
loader.call({ | ||
|
@@ -167,6 +172,13 @@ describe("loader", function() { | |
'module.exports = "<img src=\\"" + ("Hello " + (1 + 1)) + "\\">";' | ||
); | ||
}); | ||
it("should not change handling of quotes when interpolation is enabled", function() { | ||
loader.call({ | ||
query: "?interpolate" | ||
}, '<script>{"json": "with \\"quotes\\" in value"}</script>').should.be.eql( | ||
'module.exports = "<script>{\\\"json\\\": \\\"with \\\\\\\"quotes\\\\\\\" in value\\\"}</script>";' | ||
); | ||
}) | ||
it("should enable interpolations when using interpolate=require flag and only require function to be translate", function() { | ||
loader.call({ | ||
query: "?interpolate=require" | ||
|
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.
\\\\\('|")
(5) =>\\\\('|")
(4) ?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'm not sure I understand.
The two regexes could be combined into one
.replace(/\\("|')/g, "\\\\$1")
or what do you mean?