aboutsummaryrefslogtreecommitdiff
path: root/client/request.go
diff options
context:
space:
mode:
authorGravatar Alexandros Kosiaris <akosiaris@gmail.com> 2024-03-29 16:45:32 +0200
committerGravatar Frédéric Guillot <f@miniflux.net> 2024-08-18 11:35:45 -0700
commit89ff33ddd0125782ee6dbe075a3e21c0eacda15e (patch)
tree3a8d997550c3c80c20552f01921ce3ed7c8e22e0 /client/request.go
parentf3a5a3ee14f4e9b0658f0ef5e050ba2bc872bc5a (diff)
downloadv2-89ff33ddd0125782ee6dbe075a3e21c0eacda15e.tar.gz
v2-89ff33ddd0125782ee6dbe075a3e21c0eacda15e.tar.zst
v2-89ff33ddd0125782ee6dbe075a3e21c0eacda15e.zip
fix(client): Return nil and error if endpoint is empty string
Why: Passing an empty string as an endpoint to Client when instantiating a new client might seem like something that should never happen but I managed to trigger it while parsing some input files to register feeds in bulk. What: In the execute() function, check early if the endpoint is "" and then return immediately nil and a new error, named ErrEmptyEndpoint with a descriptive string
Diffstat (limited to 'client/request.go')
-rw-r--r--client/request.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/client/request.go b/client/request.go
index 45787f4d..47e1ff59 100644
--- a/client/request.go
+++ b/client/request.go
@@ -27,6 +27,7 @@ var (
ErrServerError = errors.New("miniflux: internal server error")
ErrNotFound = errors.New("miniflux: resource not found")
ErrBadRequest = errors.New("miniflux: bad request")
+ ErrEmptyEndpoint = errors.New("miniflux: empty endpoint provided")
)
type errorResponse struct {
@@ -62,6 +63,9 @@ func (r *request) Delete(path string) error {
}
func (r *request) execute(method, path string, data interface{}) (io.ReadCloser, error) {
+ if r.endpoint == "" {
+ return nil, ErrEmptyEndpoint
+ }
if r.endpoint[len(r.endpoint)-1:] == "/" {
r.endpoint = r.endpoint[:len(r.endpoint)-1]
}