diff options
Diffstat (limited to 'ext/js/extension/web-extension.js')
-rw-r--r-- | ext/js/extension/web-extension.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/js/extension/web-extension.js b/ext/js/extension/web-extension.js index 2aafbe92..bdc9b1b3 100644 --- a/ext/js/extension/web-extension.js +++ b/ext/js/extension/web-extension.js @@ -26,6 +26,13 @@ export class WebExtension extends EventDispatcher { super(); /** @type {boolean} */ this._unloaded = false; + /** @type {?string} */ + this._extensionBaseUrl = null; + try { + this._extensionBaseUrl = this.getUrl('/'); + } catch (e) { + // NOP + } } /** @type {boolean} */ @@ -105,4 +112,13 @@ export class WebExtension extends EventDispatcher { this._unloaded = true; this.trigger('unloaded', {}); } + + /** + * Checks whether or not a URL is an extension URL. + * @param {string} url The URL to check. + * @returns {boolean} `true` if the URL is an extension URL, `false` otherwise. + */ + isExtensionUrl(url) { + return this._extensionBaseUrl !== null && url.startsWith(this._extensionBaseUrl); + } } |