Skip to content

Commit

Permalink
RHINENG-10927: fix package api if package_name can be parsed as nevra
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy committed Jun 27, 2024
1 parent 7b257dd commit 6e15f4a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions manager/controllers/package_detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ var PackageSelect = database.MustGetSelect(&PackageDetailAttributes{})

func packageLatestHandler(c *gin.Context, packageName string) {
db := middlewares.DBFromContext(c)
if !packageNameIsValid(db, packageName) {
c.JSON(http.StatusBadRequest, utils.ErrorResponse{Error: "invalid package name"})
return
}

query := database.PackageByName(db, packageName)
var pkg PackageDetailAttributes
// Perform 'soft-filtering' by ordering on boolean column first
Expand Down Expand Up @@ -117,10 +112,16 @@ func PackageDetailHandler(c *gin.Context) {
return
}

nevra, err := utils.ParseNevra(parameter)
if err == nil {
packageEvraHandler(c, nevra)
} else {
db := middlewares.DBFromContext(c)
if packageNameIsValid(db, parameter) {
packageLatestHandler(c, parameter)
return
}

nevra, err := utils.ParseNevra(parameter)
if err != nil {
LogAndRespBadRequest(c, err, "invalid package name")
return
}
packageEvraHandler(c, nevra)
}

0 comments on commit 6e15f4a

Please sign in to comment.