From 80226504f4db3aa677c4e0228390e46dff0bdbc3 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Mon, 13 Jul 2026 23:21:26 +0200 Subject: [PATCH] Make XHR parameter addition less clunky --- app/assets/javascripts/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 2df2614b7..591e5fd1c 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -26,7 +26,6 @@ $(function () { OSM.loadSidebarContent = function (path, callback) { const atomSelector = "link[type=\"application/atom+xml\"]"; - let content_path = path; map.setSidebarOverlaid(false); @@ -34,16 +33,12 @@ $(function () { // Prevent caching the XHR response as a full-page URL // https://github.com/openstreetmap/openstreetmap-website/issues/5663 - if (content_path.indexOf("?") >= 0) { - content_path += "&xhr=1"; - } else { - content_path += "?xhr=1"; - } + const xhrPath = path + `${path.includes("?") ? "&" : "?"}xhr=1`; $("#sidebar_content") .empty(); - fetch(content_path, { headers: { "accept": "text/html", "x-requested-with": "XMLHttpRequest" } }) + fetch(xhrPath, { headers: { "accept": "text/html", "x-requested-with": "XMLHttpRequest" } }) .then(response => { $("#flash").empty(); $("#sidebar_loader").removeClass("delayed-fade-in").prop("hidden", true); -- 2.47.3