Skip to content

Commit

Permalink
Fix multiple host search in route
Browse files Browse the repository at this point in the history
fixes:apache#2806

Signed-off-by: Fatih USTA <[email protected]>
  • Loading branch information
fatihusta committed Jul 29, 2024
1 parent ad697c6 commit a39ffa2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion api/internal/handler/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ func uriContains(obj *entity.Route, uri string) bool {
return false
}

func hostContains(obj *entity.Route, host string) bool {
if strings.Contains(obj.Host, host) {
return true
}
for _, str := range obj.Hosts {
result := strings.Contains(str, host)
if result {
return true
}
}
return false
}

func (h *Handler) List(c droplet.Context) (interface{}, error) {
input := c.Input().(*ListInput)
labelMap, err := utils.GenLabelMap(input.Label)
Expand All @@ -239,7 +252,7 @@ func (h *Handler) List(c droplet.Context) (interface{}, error) {
return false
}

if input.Host != "" && !strings.Contains(obj.(*entity.Route).Host, input.Host) {
if input.Host != "" && !hostContains(obj.(*entity.Route), input.Host) {
return false
}

Expand Down

0 comments on commit a39ffa2

Please sign in to comment.