From 24ab2fc5f214a091900e1ae044dcc7df6698ec1d Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 1 Aug 2024 22:42:07 +0100 Subject: [PATCH] vote_chart: Remove hash part of the URL Now that the truths have anchor links, a user could select one and send the link directly to the truth, or refresh the page to there. However, the local part of the URL would be used by the script to fetch the voting data, which fail as it isn't expected by the server and is, anyway, malformed. Remove the local hash from the URL before requesting the voting data. --- static_files/vote_chart.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static_files/vote_chart.js b/static_files/vote_chart.js index f82b977..306a01d 100644 --- a/static_files/vote_chart.js +++ b/static_files/vote_chart.js @@ -1,7 +1,9 @@ const limit_ratio = 1.3 const colors = ['#b6b8fc', '#b6f4fc', '#fcb6cc', '#e0fcb6', '#fcdcb6', '#b6fcc8', '#f0b6fc'] async function main() { - const vote_response = await fetch(document.URL+"/votes"); + let current_url = new URL(document.URL) + current_url.hash = '' // Strip the local part of the URL, for example if we select a Truth + const vote_response = await fetch(current_url.toString()+"/votes"); if (!vote_response.ok) { return; }