Fix: handle nil filters (#340)

fix bug when filter is nil
This commit is contained in:
Pedro Nasser
2016-11-24 15:29:07 -02:00
committed by GitHub
parent af149045f1
commit 107033d5d7

View File

@@ -518,7 +518,7 @@ func (ds *BoltDatastore) Get(ctx context.Context, key []byte) ([]byte, error) {
}
func applyAppFilter(app *models.App, filter *models.AppFilter) bool {
if filter.Name != "" {
if filter != nil && filter.Name != "" {
nameLike, err := regexp.MatchString(strings.Replace(filter.Name, "%", ".*", -1), app.Name)
return err == nil && nameLike
}
@@ -527,7 +527,7 @@ func applyAppFilter(app *models.App, filter *models.AppFilter) bool {
}
func applyRouteFilter(route *models.Route, filter *models.RouteFilter) bool {
return (filter.Path == "" || route.Path == filter.Path) &&
return filter == nil || (filter.Path == "" || route.Path == filter.Path) &&
(filter.AppName == "" || route.AppName == filter.AppName) &&
(filter.Image == "" || route.Image == filter.Image)
}