From 7a0fdb9ce94c4a9c3432821f3360f15d7123e53f Mon Sep 17 00:00:00 2001 From: FaintSpeaker Date: Wed, 29 Dec 2021 13:56:26 -0500 Subject: [PATCH 1/2] This regular expression expects 7 potential matches. 1: The whole string 2: the alias name 3 & 4: the command text in two locations 5 & 6: the quoted command text in two styles 7: the group that selects between the two qoted styles. --- src/Alias.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Alias.ts b/src/Alias.ts index 238c531e0..bdf0315c6 100644 --- a/src/Alias.ts +++ b/src/Alias.ts @@ -38,7 +38,7 @@ export function printAliases(): void { export function parseAliasDeclaration(dec: string, global = false): boolean { const re = /^([\w|!|%|,|@|-]+)=(("(.+)")|('(.+)'))$/; const matches = dec.match(re); - if (matches == null || matches.length != 3) { + if (matches == null || matches.length != 7) { return false; } if (global) { From d823b5f28f721036abd07288a0cae9a066227d18 Mon Sep 17 00:00:00 2001 From: FaintSpeaker Date: Wed, 29 Dec 2021 14:04:58 -0500 Subject: [PATCH 2/2] Update the addAlias/addGlobalAlias calls to fetch the correct capturing groups. --- src/Alias.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Alias.ts b/src/Alias.ts index bdf0315c6..0ccc7c27c 100644 --- a/src/Alias.ts +++ b/src/Alias.ts @@ -41,10 +41,11 @@ export function parseAliasDeclaration(dec: string, global = false): boolean { if (matches == null || matches.length != 7) { return false; } + if (global) { - addGlobalAlias(matches[1], matches[2]); + addGlobalAlias(matches[1], matches[4] || matches[6]); } else { - addAlias(matches[1], matches[2]); + addAlias(matches[1], matches[4] || matches[6]); } return true; }