Skip to content

Commit

Permalink
use JSON.stringify way
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 committed Dec 2, 2024
1 parent 0696d64 commit 6c58a38
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/bindings/writeTypescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,9 @@ export function writeTypescript(
r.message.text !== null &&
r.message.text !== undefined
) {
// since we are using single quotes, escape them in the message name
const escaped = r.message.text.replace(
/'/g,
"\\'",
receivers.push(
`"${JSON.stringify(r.message.text).slice(1, -1)}"`,
);
receivers.push(`'${escaped}'`);
} else {
receivers.push(`string`);
}
Expand Down Expand Up @@ -424,12 +421,9 @@ export function writeTypescript(
});
w.append(`}`);
} else {
// since we are using single quotes, escape them in the message name
const escaped = msg.text.replace(
/'/g,
"\\'",
w.append(
`if (message === "${JSON.stringify(msg.text).slice(1, -1)}") {`,
);
w.append(`if (message === '${escaped}') {`);
w.inIndent(() => {
w.append(
`body = beginCell().storeUint(0, 32).storeStringTail(message).endCell();`,
Expand Down

0 comments on commit 6c58a38

Please sign in to comment.