From af5dd7ddd178f5841e13d4e61f7947ed04ad8331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 13 Aug 2023 19:12:27 +0200 Subject: [PATCH] extensions/shared: Don't cache detected URL The translation functions we export from extension utils must work with all extensions, not only the first that calls one of the functions. That means that we are back to examining a backtrace for every function call unless an extension defined its own translation functions with `import.meta.url`. Part-of: --- js/extensions/sharedInternals.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/extensions/sharedInternals.js b/js/extensions/sharedInternals.js index 7fed3812a..c9cb8e9c8 100644 --- a/js/extensions/sharedInternals.js +++ b/js/extensions/sharedInternals.js @@ -218,10 +218,8 @@ export class GettextWrapper { } #lookupExtension(funcName) { - if (!this.#url) - this.#url = this.#detectUrl(); - - const extension = this.#extensionClass.lookupByURL(this.#url); + const url = this.#url ?? this.#detectUrl(); + const extension = this.#extensionClass.lookupByURL(url); if (!extension) throw new Error(`${funcName} can only be called from extensions`); return extension;