From fb85f29e9ea3d91ffcc913a2904734632a0d1dbf Mon Sep 17 00:00:00 2001 From: Tijana Mitric <124770688+cod17828@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:17:36 +0100 Subject: [PATCH] MWPW-161174 fixed library query param (#3128) --- libs/blocks/library-config/library-config.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/blocks/library-config/library-config.js b/libs/blocks/library-config/library-config.js index 7605432fc6..2014a7c7ee 100644 --- a/libs/blocks/library-config/library-config.js +++ b/libs/blocks/library-config/library-config.js @@ -112,9 +112,7 @@ async function loadList(type, content, list) { } } -async function fetchLibrary(domain) { - const { searchParams } = new URL(window.location.href); - const suppliedLibrary = searchParams.get('library'); +async function fetchLibrary(domain, suppliedLibrary) { const library = suppliedLibrary || `${domain}${LIBRARY_PATH}`; try { const resp = await fetch(library); @@ -129,8 +127,9 @@ async function getSuppliedLibrary() { const { searchParams } = new URL(window.location.href); const repo = searchParams.get('repo'); const owner = searchParams.get('owner'); + const library = searchParams.get('library'); if (!repo || !owner) return null; - return fetchLibrary(`https://main--${repo}--${owner}.hlx.live`); + return fetchLibrary(`https://main--${repo}--${owner}.hlx.live`, library); } async function fetchAssetsData(path) {