From 9feadee75354710e2109f18b7c0f1d81136eefa0 Mon Sep 17 00:00:00 2001 From: Qrizzle Date: Thu, 29 Jan 2026 16:43:50 +0000 Subject: [PATCH] Update client.go --- client.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client.go b/client.go index c9491b3..fe63474 100644 --- a/client.go +++ b/client.go @@ -148,6 +148,24 @@ type ( } ) +func (p *showPasteRequestMeta) UnmarshalJSON(data []byte) error { + // First, check for an empty array literal. + if string(data) == "[]" { + // Empty slice – nothing to do, keep zero values. + return nil + } + + // Otherwise try to unmarshal as the regular object. + // We use an alias to avoid infinite recursion. + type alias showPasteRequestMeta + var tmp alias + if err := json.Unmarshal(data, &tmp); err != nil { + return err // propagate parsing errors + } + *p = showPasteRequestMeta(tmp) + return nil +} + func WithBasicAuth(username, password string) Option { return func(c *Client) { c.username = username