From e43354368ae3627e8506d5a2c780fa4cdfcc9125 Mon Sep 17 00:00:00 2001 From: Iniubong Obonguko Date: Mon, 2 Mar 2026 18:33:44 +0100 Subject: [PATCH 1/2] Enhance experiment redirection to preserve query parameters and fragments --- source/_layouts/experiment.html | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/source/_layouts/experiment.html b/source/_layouts/experiment.html index 22883aa..4f820a4 100644 --- a/source/_layouts/experiment.html +++ b/source/_layouts/experiment.html @@ -35,14 +35,25 @@ // Hash the experiment ID and bucket value reproducibly into a random number const encoder = new TextEncoder(); const data = encoder.encode(experimentId + bucket); - const hashBuffer = await crypto.subtle.digest('SHA-256', data); + const hashBuffer = await crypto + .subtle + .digest('SHA-256', data); const randomNumber = new DataView(hashBuffer).getUint32(0, true); // Select a target const target = targets[randomNumber % targets.length]; - // Replace the current history entry with the new one - window.location.replace(target); + // Replace the current history entry with the new one, preserving query parameters and fragments + const destinationUrl = new URL(target, window.location.href); + if (!destinationUrl.search) { + destinationUrl.search = window.location.search; + } + if (!destinationUrl.hash) { + destinationUrl.hash = window.location.hash; + } + window + .location + .replace(destinationUrl.toString()); } redirectToTarget(); @@ -62,4 +73,4 @@

We're conducting an experiment.

- + \ No newline at end of file From 5c5a630e23d765e4628ae43383d3eb64d3808843 Mon Sep 17 00:00:00 2001 From: Iniubong Obonguko Date: Mon, 2 Mar 2026 18:36:27 +0100 Subject: [PATCH 2/2] lint --- source/_layouts/experiment.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_layouts/experiment.html b/source/_layouts/experiment.html index 4f820a4..34a3dd4 100644 --- a/source/_layouts/experiment.html +++ b/source/_layouts/experiment.html @@ -73,4 +73,4 @@

We're conducting an experiment.

- \ No newline at end of file +