chore: improve delimiter (#8552)

This commit is contained in:
Joel
2024-09-19 17:40:20 +08:00
committed by GitHub
parent d96f5ba1ca
commit 7411bcf167
5 changed files with 103 additions and 12 deletions

View File

@@ -0,0 +1,18 @@
function escape(input: string): string {
if (!input || typeof input !== 'string')
return ''
const res = input
.replaceAll('\\', '\\\\')
.replaceAll('\0', '\\0')
.replaceAll('\b', '\\b')
.replaceAll('\f', '\\f')
.replaceAll('\n', '\\n')
.replaceAll('\r', '\\r')
.replaceAll('\t', '\\t')
.replaceAll('\v', '\\v')
.replaceAll('\'', '\\\'')
return res
}
export default escape