dmitri.shuralyov.com/website/gido/...

support explicit ?state=open query

Also disallow multiple state query parameters.

This makes query parameter handling more precise and logical.
dmitshur committed 2 years ago commit 63e65dba2eade7a188ca848401e4fd3af4441eea
changes.go
@@ -200,17 +200,19 @@ func (h *handler) serveChangesPattern(w http.ResponseWriter, req *http.Request,
}

// changeStateFilter parses the change state filter from query,
// returning an error if the value is unsupported.
func changeStateFilter(query url.Values) (change.StateFilter, error) {
	selectedTabName := query.Get(stateQueryKey)
	switch selectedTabName {
	case "":
	switch vs := query[stateQueryKey]; {
	case len(vs) == 0,
		len(vs) == 1 && vs[0] == "open":
		return change.FilterOpen, nil
	case "closed":
	case len(vs) == 1 && vs[0] == "closed":
		return change.FilterClosedMerged, nil
	case "all":
	case len(vs) == 1 && vs[0] == "all":
		return change.FilterAll, nil
	case len(vs) == 1:
		return "", fmt.Errorf("unsupported state filter value: %q", vs[0])
	default:
		return "", fmt.Errorf("unsupported state filter value: %q", selectedTabName)
		return "", fmt.Errorf("multiple state filters are not supported: %q", vs)
	}
}
issues.go
@@ -206,17 +206,19 @@ const (
)

// issueStateFilter parses the issue state filter from query,
// returning an error if the value is unsupported.
func issueStateFilter(query url.Values) (issues.StateFilter, error) {
	selectedTabName := query.Get(stateQueryKey)
	switch selectedTabName {
	case "":
	switch vs := query[stateQueryKey]; {
	case len(vs) == 0,
		len(vs) == 1 && vs[0] == "open":
		return issues.StateFilter(issues.OpenState), nil
	case "closed":
	case len(vs) == 1 && vs[0] == "closed":
		return issues.StateFilter(issues.ClosedState), nil
	case "all":
	case len(vs) == 1 && vs[0] == "all":
		return issues.AllStates, nil
	case len(vs) == 1:
		return "", fmt.Errorf("unsupported state filter value: %q", vs[0])
	default:
		return "", fmt.Errorf("unsupported state filter value: %q", selectedTabName)
		return "", fmt.Errorf("multiple state filters are not supported: %q", vs)
	}
}