From b6c20e57f9b26438b5ac6e0e6365d9416b977331 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 30 Dec 2023 12:14:52 +0100 Subject: [PATCH] Ignore mailto links --- client.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client.go b/client.go index 7c1ff75..0833753 100644 --- a/client.go +++ b/client.go @@ -75,6 +75,9 @@ type client struct { // Supported URL schemas: // - gemini // - http/https +// +// Some schemas automatically return success: +// - mailto func NewClient(opts *ClientOpts) Client { return &client{*opts.withDefaults()} } @@ -240,6 +243,12 @@ func (c *client) getHTTP( } } +func (c *client) noOpGet() ( + string, io.ReadCloser, error, +) { + return "", emptyReadCloser(), nil +} + func (c *client) get( ctx context.Context, url URL, redirectDepth int, ) ( @@ -252,6 +261,8 @@ func (c *client) get( return c.getGemini(ctx, url, redirectDepth) case "http", "https": return c.getHTTP(ctx, url, redirectDepth) + case "mailto": + return c.noOpGet() default: return "", nil, fmt.Errorf("unsupported scheme %q", scheme) }