Browse Source

Change aliases API to accept aliases with $ prefix

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
9d0d5d705b
  1. 11
      sources/Aliases/AliasSource.uc

11
sources/Aliases/AliasSource.uc

@ -163,7 +163,8 @@ public function bool HasAlias(Text alias)
* (as well as it's `Aliases` objects). * (as well as it's `Aliases` objects).
* *
* @param alias Alias, for which method will attempt to return * @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 * @param copyOnFailure Whether method should return copy of original
* `alias` value in case caller source did not have any records * `alias` value in case caller source did not have any records
* corresponding to `alias`. * corresponding to `alias`.
@ -180,7 +181,13 @@ public function Text Resolve(Text alias, optional bool copyOnFailure)
if (alias == none) { if (alias == none) {
return 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)); result = Text(aliasHash.GetItem(lowerCaseAlias));
lowerCaseAlias.FreeSelf(); lowerCaseAlias.FreeSelf();
if (result != none) { if (result != none) {

Loading…
Cancel
Save