react-runner icon indicating copy to clipboard operation
react-runner copied to clipboard

Escaping code

Open robaolana opened this issue 1 year ago • 0 comments

The console throws errors when code that has a line with backticks is run.

console.log(Logging in with ${provider});

I tried to escape special characters but that doesn't seem to work.

const escapeCode = (code: string) => { return code .replace(/\\/g, '\\\\') // Escape backslashes first .replace(//g, '\') // Escape backticks .replace(/\$/g, '\\$'); // Escape dollar signs };

Is there a straightforward solution?

robaolana avatar Oct 27 '24 00:10 robaolana