From 9528ef529b0cf5a45fc7b25b7aed43f54544c28d Mon Sep 17 00:00:00 2001 From: Liam Bigelow <40188355+bglw@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:17:26 +1200 Subject: [PATCH] Add safety checks around accesses for `document.currentScript.src` --- pagefind_ui/default/svelte/ui.svelte | 16 +++++++++++++--- pagefind_ui/default/ui-core.js | 9 ++++++--- pagefind_ui/modular/modular-core.js | 27 ++++++++++++++++++++------- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/pagefind_ui/default/svelte/ui.svelte b/pagefind_ui/default/svelte/ui.svelte index 4be04d55..a40b5867 100644 --- a/pagefind_ui/default/svelte/ui.svelte +++ b/pagefind_ui/default/svelte/ui.svelte @@ -99,11 +99,21 @@ [ `Pagefind couldn't be loaded from ${this.options.bundlePath}pagefind.js`, `You can configure this by passing a bundlePath option to PagefindUI`, - `[DEBUG: Loaded from ${ - document?.currentScript?.src ?? "no known script location" - }]`, ].join("\n") ); + // Important: Check that the element is indeed a