From f0016b5368ecf1ff7b20f52cd266ea9f7fcffbd4 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 14 May 2024 23:43:17 +0300 Subject: [PATCH] Fallback for old safari --- .../SlashCommandAutoCompleteNameResult.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/scripts/slash-commands/SlashCommandAutoCompleteNameResult.js b/public/scripts/slash-commands/SlashCommandAutoCompleteNameResult.js index 80ed27a37..ba163fcd5 100644 --- a/public/scripts/slash-commands/SlashCommandAutoCompleteNameResult.js +++ b/public/scripts/slash-commands/SlashCommandAutoCompleteNameResult.js @@ -50,6 +50,14 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult { } getNamedArgumentAt(text, index, isSelect) { + function getSplitRegex() { + try { + return new RegExp('(?<==)'); + } catch { + // For browsers that don't support lookbehind + return new RegExp('=(.*)'); + } + } const notProvidedNamedArguments = this.executor.command.namedArgumentList.filter(arg=>!this.executor.namedArgumentList.find(it=>it.name == arg.name)); let name; let value; @@ -62,7 +70,7 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult { // cursor is somewhere within the named arguments (including final space) argAssign = this.executor.namedArgumentList.find(it=>it.start <= index && it.end >= index); if (argAssign) { - const [argName, ...v] = text.slice(argAssign.start, index).split(/(?<==)/); + const [argName, ...v] = text.slice(argAssign.start, index).split(getSplitRegex()); name = argName; value = v.join(''); start = argAssign.start;