Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Escape Newline/Paragraph separators #18

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module.exports = function(source) {
var value = typeof source === "string" ? JSON.parse(source) : source;
var options = loaderUtils.getOptions(this) || {};
value = JSON.stringify(value)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
value = options.stringify ? `'${value}'` : value
var module = this.version && this.version >= 2 ? `export default ${value};` : `module.exports = ${value};`;
return module
Expand Down