From dac1c84c4b05bc1e8566ad7363da4d4f0bceee9d Mon Sep 17 00:00:00 2001 From: Will Hannon Date: Tue, 13 Feb 2024 14:34:42 -0800 Subject: [PATCH] Ignore query strings in Altair component --- .vitepress/theme/Altair.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.vitepress/theme/Altair.vue b/.vitepress/theme/Altair.vue index d9d9d1a..df56bb5 100644 --- a/.vitepress/theme/Altair.vue +++ b/.vitepress/theme/Altair.vue @@ -21,16 +21,22 @@ export default { methods: { async loadChart(url) { try { + + // Get the path to check the file format + const urlObj = new URL(url); + const path = urlObj.pathname; + + // Get the response from the URL const response = await fetch(url); let spec; // Check if URL ends with '.html' - if (url.endsWith('.html')) { + if (path.endsWith('.html')) { const htmlContent = await response.text(); spec = await parseVegaSpecFromHTML(htmlContent); } // Check if URL ends with '.json' - else if (url.endsWith('.json')) { + else if (path.endsWith('.json')) { spec = await response.json(); } else {