From 28269aa329d23b32bc0d94d332ce97f94a4e7bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Sun, 31 Jan 2021 18:41:48 +0100 Subject: [PATCH] fix: start and end parameter parsing for wakatime summary route --- routes/compat/wakatime/v1/summaries.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/compat/wakatime/v1/summaries.go b/routes/compat/wakatime/v1/summaries.go index 62102e8..0bbf7a6 100644 --- a/routes/compat/wakatime/v1/summaries.go +++ b/routes/compat/wakatime/v1/summaries.go @@ -69,12 +69,17 @@ func (h *SummariesHandler) loadUserSummaries(r *http.Request) ([]*models.Summary var start, end time.Time if rangeParam != "" { + // range param takes precedence if err, parsedFrom, parsedTo := utils.ResolveInterval(rangeParam); err == nil { start, end = parsedFrom, parsedTo } else { return nil, errors.New("invalid 'range' parameter"), http.StatusBadRequest } + } else if err, parsedFrom, parsedTo := utils.ResolveInterval(rangeParam); err == nil && start == end { + // also accept start param to be a range param + start, end = parsedFrom, parsedTo } else { + // eventually, consider start and end params a date var err error start, err = time.Parse(time.RFC3339, strings.Replace(startParam, " ", "+", 1))