botbuilder-dialogs
Version:
A dialog stack based conversation manager for Microsoft BotBuilder.
40 lines • 1.3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.AliasPathResolver = void 0;
/**
* Maps aliasXXX -> path.xxx ($foo => dialog.foo).
*/
class AliasPathResolver {
/**
* Initializes a new instance of the [AliasPathResolver](xref:botbuilder-dialogs.AliasPathResolver) class.
*
* @param alias Alias name.
* @param prefix Prefix name.
* @param postfix Postfix name.
*/
constructor(alias, prefix, postfix) {
this.alias = alias.trim();
this.prefix = prefix.trim();
this.postfix = postfix ? postfix.trim() : '';
}
/**
* Transforms the path.
*
* @param path Path to inspect.
* @returns The transformed path.
*/
transformPath(path) {
const start = path.indexOf(this.alias);
if (start == 0) {
// here we only deals with trailing alias, alias in middle be handled in further breakdown
// $xxx -> path.xxx
path = `${this.prefix}${path.substr(start + this.alias.length)}${this.postfix}`;
if (path.endsWith('.')) {
path = path.substr(0, path.length - 1);
}
}
return path;
}
}
exports.AliasPathResolver = AliasPathResolver;
//# sourceMappingURL=aliasPathResolver.js.map
;