Compute identifier in context module in constructor

This commit is contained in:
Mihail Bodrov 2018-03-24 19:02:30 +01:00
parent 8c11da5219
commit ee22d498fe
1 changed files with 6 additions and 3 deletions

View File

@ -45,7 +45,7 @@ class ContextModule extends Module {
if (typeof options.mode !== "string")
throw new Error("options.mode is a required option");
this._identifier = null;
this._identifier = this._createIdentifier();
}
prettyRegExp(regexString) {
@ -66,8 +66,7 @@ class ContextModule extends Module {
.join("!");
}
identifier() {
if (this._identifier) return this._identifier;
_createIdentifier() {
let identifier = this.context;
if (this.options.resourceQuery)
identifier += ` ${this.options.resourceQuery}`;
@ -86,6 +85,10 @@ class ContextModule extends Module {
return identifier;
}
identifier() {
return this._identifier;
}
readableIdentifier(requestShortener) {
let identifier = requestShortener.shorten(this.context);
if (this.options.resourceQuery)