Commit 4e5b18ba authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Enforce non-empty configuration when boot script is run from the browser extension

parent 1c07780a
......@@ -21,6 +21,18 @@ if (isBrowserSupported()) {
const config = /** @type {AnnotatorConfig|SidebarAppConfig} */ (
parseJsonConfig(document)
);
// When the boot script is executed from the browser extension, at least one
// config is required
const isExtensionContext = !!(
/** @type {any} */ (window).chrome?.runtime?.id
);
if (!Object.keys(config).length && isExtensionContext) {
throw new Error(
'Could not start Hypothesis extension as configuration is missing'
);
}
const assetRoot = processUrlTemplate(config.assetRoot || '__ASSET_ROOT__');
// Check whether this is the sidebar app (indicated by the presence of a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment