UNPKG

sanitize-utils

Version:

A utility function to sanitize quotes in strings (escape ' and ")

7 lines (6 loc) 264 B
function sanitizeQuotes(str) { return str.replace(/"/g, '\\"').replace(/'/g, "\\'"); } module.exports = sanitizeQuotes; // This function replaces double quotes with escaped double quotes // and single quotes with escaped single quotes in the input string.