Fix expires label

This commit is contained in:
2026-09-13 09:14:27 +02:00
parent b24467c37d
commit ad611e9652
3 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -78,8 +78,8 @@ func TestFormatRoundTrips(t *testing.T) {
if got, err := ParseDuration(FormatDuration(d)); err != nil || got != d { 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) 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 // FormatLifetime is shown next to the field a caller types into, so
// what it prints has to be something a caller could type back. // what it prints has to be something ParseDuration would accept.
if got, err := ParseDuration(FormatLifetime(d)); err != nil || got != d { 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) t.Errorf("FormatLifetime(%s) = %q, which parses back to %s (%v)", d, FormatLifetime(d), got, err)
} }
+9 -4
View File
@@ -48,10 +48,14 @@ type indexPage struct {
MaxSize string MaxSize string
MaxExpiry string MaxExpiry string
DefaultExpiry string DefaultExpiry string
AbsBase string // ExpiryHint is the same lifetime as DefaultExpiry, worded for the form's
AllowVanity bool // "Expires in" field rather than for a row in the limits list: what the
MaxSizeBytes int64 // 0 when unlimited; the script checks against it // field wants is "never", what the list wants is "unlimited".
Stale bool // a login whose token no longer exists 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) { 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), MaxSize: config.FormatSize(lim.MaxSize),
MaxExpiry: config.FormatLifetime(lim.MaxExpiry), MaxExpiry: config.FormatLifetime(lim.MaxExpiry),
DefaultExpiry: config.FormatLifetime(lim.DefaultExpiry), DefaultExpiry: config.FormatLifetime(lim.DefaultExpiry),
ExpiryHint: config.FormatDuration(lim.DefaultExpiry),
AbsBase: s.absBase(r), AbsBase: s.absBase(r),
AllowVanity: lim.AllowVanity, AllowVanity: lim.AllowVanity,
MaxSizeBytes: lim.MaxSize, MaxSizeBytes: lim.MaxSize,
+1 -1
View File
@@ -14,7 +14,7 @@
<div class="row"> <div class="row">
<label class="field"> <label class="field">
<span>Expires in</span> <span>Expires in</span>
<input type="text" name="expiry" id="expiry" placeholder="{{.DefaultExpiry}}" autocomplete="off"> <input type="text" name="expiry" id="expiry" placeholder="{{.ExpiryHint}}" autocomplete="off">
</label> </label>
<label class="field"> <label class="field">
<span>Custom name <em>({{if .AllowVanity}}optional{{else}}needs a token{{end}})</em></span> <span>Custom name <em>({{if .AllowVanity}}optional{{else}}needs a token{{end}})</em></span>