Skip to content

Commit 5fac898

Browse files
committed
Fix escaping and unescaping strings with backslashes
1 parent 9f135fc commit 5fac898

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

example/locales/de.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"Hello world!": "Hallo Welt!",
33
"Lazy term": "Fauler Begriff",
4-
"This text contains {0} \\{} curly braces and \\\\{\\{}}\\{0}.": "Dieser Text enthält {0} \\{} geschweifte Klammern und \\\\{\\{}}\\{0}.",
5-
"Untranslated text": ""
4+
"Untranslated text": "",
5+
"Unknown Error": "",
6+
"An unexpected error occurred while processing your request.": "",
7+
"This text contains {0} \\{} curly braces and \\\\\\{\\{}}\\{0}.": "Dieser Text enthält {0} \\{} geschweifte Klammern und \\\\\\{\\{}}\\{0}."
68
}

example/locales/en.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"Hello world!": "Hello world!",
33
"Lazy term": "Lazy term",
4-
"This text contains {0} \\{} curly braces and \\\\{\\{}}\\{0}.": "This text contains {0} \\{} curly braces and \\\\{\\{}}\\{0}.",
5-
"Untranslated text": "Untranslated text"
4+
"Untranslated text": "Untranslated text",
5+
"Unknown Error": "Unknown Error",
6+
"An unexpected error occurred while processing your request.": "An unexpected error occurred while processing your request.",
7+
"This text contains {0} \\{} curly braces and \\\\\\{\\{}}\\{0}.": "This text contains {0} \\{} curly braces and \\\\\\{\\{}}\\{0}."
68
}

lib/common/unescapeKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export function unescapeKey(key: string): string {
2-
return key.replaceAll(/\\{/g, "{");
2+
return key.replaceAll(/\\{/g, "{").replaceAll(/\\\\/g, "\\");
33
}

0 commit comments

Comments
 (0)