Escape pipe symbol in string.gsub (#1370)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user