react-runner
react-runner copied to clipboard
Escaping code
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?