From ced0492065a1d619b3dcb0cb1e91359a555ada6b Mon Sep 17 00:00:00 2001 From: Sergey Vilgelm Date: Mon, 22 Dec 2025 07:53:03 -0800 Subject: [PATCH 1/3] keyserver: share/give a link to specific email lookup Auto-fill the lookup form when an ?email= query parameter is present in the page URL and automatically submit the form. This adds a small client-side snippet that reads the "email" parameter, populates the lookup-email input, and triggers requestSubmit() on the lookup-form. This improves user experience by allowing direct links that pre-populate and run key lookups without extra clicks, useful for sharing and deep linking to specific email lookups. The change is isolated to the home template and does not affect existing lookup behavior when no parameter is provided. --- cmd/age-keyserver/templates/home.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/age-keyserver/templates/home.html b/cmd/age-keyserver/templates/home.html index 3e8a603..3acd857 100644 --- a/cmd/age-keyserver/templates/home.html +++ b/cmd/age-keyserver/templates/home.html @@ -115,6 +115,13 @@

Submit or manage your key

resultDiv.innerHTML = '

Error looking up key.

'; } }); + + let params = new URLSearchParams(document.location.search); + let emailParam = params.get("email") + if (emailParam !== null) { + document.getElementById('lookup-email').value = emailParam; + document.getElementById('lookup-form').requestSubmit(); + } From 6d5a20983113a8a609c7e22d2bb68fea8165b0de Mon Sep 17 00:00:00 2001 From: Sergey Vilgelm Date: Mon, 22 Dec 2025 08:05:24 -0800 Subject: [PATCH 2/3] defer email param autofill until DOMContentLoaded Ensure the email query parameter is read and applied only after the DOM has finished loading. Previously the script accessed and submitted the lookup form immediately, which could run before DOM elements were available and cause race conditions or errors. Wrapping the logic in a DOMContentLoaded listener guarantees the form and input exist before setting the value and programmatically submitting. --- cmd/age-keyserver/templates/home.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/age-keyserver/templates/home.html b/cmd/age-keyserver/templates/home.html index 3acd857..77499dc 100644 --- a/cmd/age-keyserver/templates/home.html +++ b/cmd/age-keyserver/templates/home.html @@ -116,12 +116,14 @@

Submit or manage your key

} }); - let params = new URLSearchParams(document.location.search); - let emailParam = params.get("email") - if (emailParam !== null) { - document.getElementById('lookup-email').value = emailParam; - document.getElementById('lookup-form').requestSubmit(); - } + document.addEventListener("DOMContentLoaded", () => { + const params = new URLSearchParams(document.location.search); + const emailParam = params.get("email"); + if (emailParam !== null) { + document.getElementById('lookup-email').value = emailParam; + document.getElementById('lookup-form').requestSubmit(); + } + }); From 7ede7e1b4f7593aba13bf26e73c4b500923b7266 Mon Sep 17 00:00:00 2001 From: Sergey Vilgelm <523825+SVilgelm@users.noreply.github.com> Date: Mon, 22 Dec 2025 09:56:01 -0800 Subject: [PATCH 3/3] move the code to initLookupFromQuery function Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cmd/age-keyserver/templates/home.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/age-keyserver/templates/home.html b/cmd/age-keyserver/templates/home.html index 77499dc..5eff1a8 100644 --- a/cmd/age-keyserver/templates/home.html +++ b/cmd/age-keyserver/templates/home.html @@ -116,14 +116,20 @@

Submit or manage your key

} }); - document.addEventListener("DOMContentLoaded", () => { + function initLookupFromQuery() { const params = new URLSearchParams(document.location.search); const emailParam = params.get("email"); if (emailParam !== null) { document.getElementById('lookup-email').value = emailParam; document.getElementById('lookup-form').requestSubmit(); } - }); + } + + if (document.readyState === 'loading') { + document.addEventListener("DOMContentLoaded", initLookupFromQuery); + } else { + initLookupFromQuery(); + }