Escape pipe symbol in string.gsub (#1370)

This commit is contained in:
Lennart Ochel
2025-05-04 20:36:46 +02:00
committed by GitHub
parent 16d947b285
commit 0b1051c2af
2 changed files with 11 additions and 1 deletions
+2 -1
View File
@@ -39,6 +39,7 @@ function translatePattern(pattern: string): string {
// Replace single backslash with double backslashes
pattern = pattern.replace(new RegExp("\\\\", "g"), "\\\\");
pattern = pattern.replace(new RegExp("\\|", "g"), "\\|");
for (const [key, value] of Object.entries(ROSETTA_STONE)) {
pattern = pattern.replace(new RegExp(key, "g"), value);
@@ -138,7 +139,7 @@ export const stringApi = new LuaTable({
repl: any, // string or LuaFunction
n = Infinity,
) => {
pattern = translatePattern("" + pattern);
pattern = translatePattern(pattern);
const replIsFunction = repl.call;
let count = 0,