mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 11:29:01 +00:00
Update parseGetParams to call strconv.Atoi when params are valid
This commit is contained in:
parent
52210a57f0
commit
61bc129e1d
@ -236,17 +236,17 @@ func parseGetParams(query string) getParams {
|
|||||||
for _, pair := range strings.Split(query, "&") {
|
for _, pair := range strings.Split(query, "&") {
|
||||||
parts := strings.SplitN(pair, "=", 2)
|
parts := strings.SplitN(pair, "=", 2)
|
||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
val, err := strconv.Atoi(parts[1])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
switch parts[0] {
|
switch parts[0] {
|
||||||
case "limit":
|
case "limit", "offset":
|
||||||
|
if val, err := strconv.Atoi(parts[1]); err == nil {
|
||||||
|
if parts[0] == "limit" {
|
||||||
params.limit = val
|
params.limit = val
|
||||||
case "offset":
|
} else {
|
||||||
params.offset = val
|
params.offset = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user