We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e4e5386 commit 498ce0dCopy full SHA for 498ce0d
1 file changed
src/pkg/utils/utils.ts
@@ -17,14 +17,11 @@ export function randomString(e: number) {
17
return n;
18
}
19
20
-export function dealSymbol(source: string): string {
21
- source = source.replace(/("|\\)/g, "\\$1");
22
- source = source.replace(/(\r\n|\n)/g, "\\n");
23
- return source;
24
-}
25
-
26
export function dealScript(source: string): string {
27
- return dealSymbol(source);
+ // 双引号会加quote. 其他特殊字符也会转换一下。然后整个文字加双引号表示字串
+ // 例子 `This is a "Apple".\n123\n\r456` => `"This is a \\"Apple\\".\\n123\\n\\r456"`
+ // 兼容旧代码,头尾引号删去。
+ return JSON.stringify(source).slice(1, -1);
28
29
30
export function isFirefox(): boolean {
0 commit comments