MCPcopy
hub / github.com/cli/cli / addPerPage

Function addPerPage

pkg/cmd/api/pagination.go:94–110  ·  view source on GitHub ↗
(p string, perPage int, params map[string]interface{})

Source from the content-addressed store, hash-verified

92}
93
94func addPerPage(p string, perPage int, params map[string]interface{}) string {
95 if _, hasPerPage := params["per_page"]; hasPerPage {
96 return p
97 }
98
99 idx := strings.IndexRune(p, '?')
100 sep := "?"
101
102 if idx >= 0 {
103 if qp, err := url.ParseQuery(p[idx+1:]); err == nil && qp.Get("per_page") != "" {
104 return p
105 }
106 sep = "&"
107 }
108
109 return fmt.Sprintf("%s%sper_page=%d", p, sep, perPage)
110}
111
112// paginatedArrayReader wraps a Reader to omit the opening and/or the closing square bracket of a
113// JSON array in order to apply pagination context between multiple API requests.

Callers 2

apiRunFunction · 0.85
Test_addPerPageFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by 1

Test_addPerPageFunction · 0.68