diff --git a/docs/_overrides/main.html b/docs/_overrides/main.html index 5f7a8b75..69ae2e6c 100644 --- a/docs/_overrides/main.html +++ b/docs/_overrides/main.html @@ -40,8 +40,20 @@ // above it. Resolving the bare relative `base_url` against `location` // yields an absolute URL; popping only the page's last path segment (the // previous approach) 404s on deep pages. - var versionRoot = new URL("{{ base_url }}/", window.location); - var versionsUrl = new URL("../versions.json", versionRoot).toString(); + // + // AAASM-4317: guard the URL constructors so that a malformed or empty + // template value (e.g. a stray build variant where `base_url` renders + // blank) cannot throw `TypeError: Failed to construct 'URL': Invalid URL` + // and leave a visible page-load error in the console. On failure we keep + // the static fallback copy that is already rendered above. + var versionRoot; + var versionsUrl; + try { + versionRoot = new URL("{{ base_url }}/", window.location); + versionsUrl = new URL("../versions.json", versionRoot).toString(); + } catch (e) { + return; + } // The current version id is the last path segment of the deploy root. var current = diff --git a/docs/_overrides/partials/javascripts/outdated.html b/docs/_overrides/partials/javascripts/outdated.html index a3062a0d..5b312f4d 100644 --- a/docs/_overrides/partials/javascripts/outdated.html +++ b/docs/_overrides/partials/javascripts/outdated.html @@ -7,8 +7,11 @@ `..`, which is not an absolute URL, so `new URL("..")` throws `TypeError: Failed to construct 'URL': Invalid URL` on every page load. - The only change here is passing `location` as the base so the relative - `base_url` resolves against the current page. Behaviour is otherwise identical - to Material's generated script. + Passing `location` as the base resolves the relative `base_url` against the + current page. The try/catch (AAASM-4317) is defense-in-depth: any future + template regression that renders `base_url` as an unparseable value (e.g. an + empty string on a build variant that omits `site_url`) will silently no-op + the outdated banner instead of surfacing a page-load TypeError. Behaviour is + otherwise identical to Material's generated script. -#} - + diff --git a/docs/verify/AAASM-4317-clean-console.png b/docs/verify/AAASM-4317-clean-console.png new file mode 100644 index 00000000..b487fdd8 Binary files /dev/null and b/docs/verify/AAASM-4317-clean-console.png differ diff --git a/docs/verify/pr2-guides-nested.png b/docs/verify/pr2-guides-nested.png new file mode 100644 index 00000000..bbae753b Binary files /dev/null and b/docs/verify/pr2-guides-nested.png differ