From ee22d498fe6d415b2ed33249dead90020ee55cfd Mon Sep 17 00:00:00 2001 From: Mihail Bodrov Date: Sat, 24 Mar 2018 19:02:30 +0100 Subject: [PATCH] Compute identifier in context module in constructor --- lib/ContextModule.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ContextModule.js b/lib/ContextModule.js index 1fcdad3e0..c34a6d884 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -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)