From 9d0d5d705b43cc699b86d670a46509eabaf5f679 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Tue, 30 Nov 2021 00:16:55 +0700 Subject: [PATCH] Change aliases API to accept aliases with $ prefix --- sources/Aliases/AliasSource.uc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/Aliases/AliasSource.uc b/sources/Aliases/AliasSource.uc index 0d39dd1..90b6100 100644 --- a/sources/Aliases/AliasSource.uc +++ b/sources/Aliases/AliasSource.uc @@ -163,7 +163,8 @@ public function bool HasAlias(Text alias) * (as well as it's `Aliases` objects). * * @param alias Alias, for which method will attempt to return - * a value. Case-insensitive. + * a value. Case-insensitive. If given `alias` starts with "$" character - + * that character will be removed before resolving that alias. * @param copyOnFailure Whether method should return copy of original * `alias` value in case caller source did not have any records * corresponding to `alias`. @@ -180,7 +181,13 @@ public function Text Resolve(Text alias, optional bool copyOnFailure) if (alias == none) { return none; } - lowerCaseAlias = alias.LowerCopy(); + // Automatically get rid of "$" prefix, if present + if (alias.StartsWith(P("$"))) { + lowerCaseAlias = alias.LowerCopy(1); + } + else { + lowerCaseAlias = alias.LowerCopy(); + } result = Text(aliasHash.GetItem(lowerCaseAlias)); lowerCaseAlias.FreeSelf(); if (result != none) {