From 107033d5d79b40897df73f3d4d5063053b93035c Mon Sep 17 00:00:00 2001 From: Pedro Nasser Date: Thu, 24 Nov 2016 15:29:07 -0200 Subject: [PATCH] Fix: handle nil filters (#340) fix bug when filter is nil --- api/datastore/bolt/bolt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/datastore/bolt/bolt.go b/api/datastore/bolt/bolt.go index 03abafc99..a67401fcd 100644 --- a/api/datastore/bolt/bolt.go +++ b/api/datastore/bolt/bolt.go @@ -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) }