Ignore mailto links

This commit is contained in:
Brian Picciano 2023-12-30 12:14:52 +01:00
parent 1c91c0368c
commit b6c20e57f9

View File

@ -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)
}