From ad611e9652ce2ab69ff2bc1a20eac7ca973b1748 Mon Sep 17 00:00:00 2001 From: Thayol Date: Sun, 13 Sep 2026 09:14:27 +0200 Subject: [PATCH] Fix expires label --- internal/config/config_test.go | 4 ++-- internal/server/pages.go | 13 +++++++++---- web/templates/index.html | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index a4430fb..f7049d1 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -78,8 +78,8 @@ func TestFormatRoundTrips(t *testing.T) { if got, err := ParseDuration(FormatDuration(d)); err != nil || got != d { t.Errorf("FormatDuration(%s) = %q, which parses back to %s (%v)", d, FormatDuration(d), got, err) } - // FormatLifetime reaches the upload form as the expiry placeholder, so - // what it prints has to be something a caller could type back. + // FormatLifetime is shown next to the field a caller types into, so + // what it prints has to be something ParseDuration would accept. if got, err := ParseDuration(FormatLifetime(d)); err != nil || got != d { t.Errorf("FormatLifetime(%s) = %q, which parses back to %s (%v)", d, FormatLifetime(d), got, err) } diff --git a/internal/server/pages.go b/internal/server/pages.go index d8d5383..63d6d11 100644 --- a/internal/server/pages.go +++ b/internal/server/pages.go @@ -48,10 +48,14 @@ type indexPage struct { MaxSize string MaxExpiry string DefaultExpiry string - AbsBase string - AllowVanity bool - MaxSizeBytes int64 // 0 when unlimited; the script checks against it - Stale bool // a login whose token no longer exists + // ExpiryHint is the same lifetime as DefaultExpiry, worded for the form's + // "Expires in" field rather than for a row in the limits list: what the + // field wants is "never", what the list wants is "unlimited". + ExpiryHint string + AbsBase string + AllowVanity bool + MaxSizeBytes int64 // 0 when unlimited; the script checks against it + Stale bool // a login whose token no longer exists } func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { @@ -71,6 +75,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { MaxSize: config.FormatSize(lim.MaxSize), MaxExpiry: config.FormatLifetime(lim.MaxExpiry), DefaultExpiry: config.FormatLifetime(lim.DefaultExpiry), + ExpiryHint: config.FormatDuration(lim.DefaultExpiry), AbsBase: s.absBase(r), AllowVanity: lim.AllowVanity, MaxSizeBytes: lim.MaxSize, diff --git a/web/templates/index.html b/web/templates/index.html index e411590..b30fe2a 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -14,7 +14,7 @@