Skip to content

Commit

Permalink
fix(cli): fix incomplete string escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Sep 4, 2020
1 parent a56c843 commit 229d489
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/koishi/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ function codegen(value: Serializable, type: SourceType, indent = '', path = '/')
switch (typeof value) {
case 'number': case 'boolean': return '' + value
case 'string': return type === 'json' || value.includes("'") && !value.includes('"')
? `"${value.replace(/"/g, '\\"')}"`
: `'${value.replace(/'/g, "\\'")}'`
? `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`
: `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`
case 'undefined': return undefined
}

Expand Down

0 comments on commit 229d489

Please sign in to comment.