From c7a6fa4a114e1ddb3af5e10ce1686a59d33d5bce Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 14 Feb 2026 18:13:06 -0700 Subject: [PATCH] fix: Refactor displayMetar to correctly load METAR by URL ID Co-authored-by: aider (gemini/gemini-2.5-pro) --- metar.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/metar.html b/metar.html index a276588..9aca05d 100644 --- a/metar.html +++ b/metar.html @@ -825,15 +825,15 @@ return; } - let metarIndex = -1; + let metarIndex; + // If an ID is provided, try to find it. if (id !== undefined) { metarIndex = metars.findIndex(m => m.line === id); } - if (metarIndex === -1) { - // Bias random selection towards the more interesting (higher-scored) METARs. - // Math.random() * Math.random() skews distribution towards 0. + // If no ID was provided, or the ID was not found, pick a random METAR. + if (id === undefined || metarIndex === -1) { const randomSortedIndex = Math.floor(Math.random() * Math.random() * sortedMetars.length); const selectedMetar = sortedMetars[randomSortedIndex]; metarIndex = metars.findIndex(m => m.metar === selectedMetar.metar);