Skip to content

Commit bedd7b2

Browse files
guillep2ktechknowlogicklafriks
committed
Fix error logged when repos qs is empty (#9591)
* Fix error logged when repos qs is empty * Update routers/user/home.go Co-Authored-By: Lauris BH <[email protected]> Co-authored-by: techknowlogick <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 4a768e1 commit bedd7b2

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

routers/user/home.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,21 +389,23 @@ func Issues(ctx *context.Context) {
389389

390390
reposQuery := ctx.Query("repos")
391391
var repoIDs []int64
392-
if issueReposQueryPattern.MatchString(reposQuery) {
393-
// remove "[" and "]" from string
394-
reposQuery = reposQuery[1 : len(reposQuery)-1]
395-
//for each ID (delimiter ",") add to int to repoIDs
396-
for _, rID := range strings.Split(reposQuery, ",") {
397-
// Ensure nonempty string entries
398-
if rID != "" && rID != "0" {
399-
rIDint64, err := strconv.ParseInt(rID, 10, 64)
400-
if err == nil {
401-
repoIDs = append(repoIDs, rIDint64)
392+
if len(reposQuery) != 0 {
393+
if issueReposQueryPattern.MatchString(reposQuery) {
394+
// remove "[" and "]" from string
395+
reposQuery = reposQuery[1 : len(reposQuery)-1]
396+
//for each ID (delimiter ",") add to int to repoIDs
397+
for _, rID := range strings.Split(reposQuery, ",") {
398+
// Ensure nonempty string entries
399+
if rID != "" && rID != "0" {
400+
rIDint64, err := strconv.ParseInt(rID, 10, 64)
401+
if err == nil {
402+
repoIDs = append(repoIDs, rIDint64)
403+
}
402404
}
403405
}
406+
} else {
407+
log.Error("issueReposQueryPattern not match with query")
404408
}
405-
} else {
406-
log.Error("issueReposQueryPattern not match with query")
407409
}
408410

409411
isShowClosed := ctx.Query("state") == "closed"

0 commit comments

Comments
 (0)