From b19725bb88294532fc3860e008a831403f8290e1 Mon Sep 17 00:00:00 2001 From: Danylo Kuvshynov Date: Tue, 13 Apr 2021 15:22:24 +0300 Subject: [PATCH] Fix issue https://github.com/alcounit/selenosis/issues/33 --- handlers.go | 14 ++++++++++---- selenosis.go | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/handlers.go b/handlers.go index 6bdefc7..8bf143a 100644 --- a/handlers.go +++ b/handlers.go @@ -375,11 +375,17 @@ func (app *App) HandleStatus(w http.ResponseWriter, r *http.Request) { } func parseImage(image string) (container string) { - pref, err := regexp.Compile("[^a-zA-Z0-9]+") - if err != nil { - return "selenoid-browser" + browser := "browser" + if len(image) > 0 { + pref, err := regexp.Compile("[^a-zA-Z0-9]+") + if err != nil { + return browser + } + fragments := strings.Split(image, "/") + image = fragments[len(fragments)-1] + return pref.ReplaceAllString(image, "-") } - return pref.ReplaceAllString(image, "-") + return browser } func getSessionStats(sessions []platform.Service) (active []platform.Service, pending []platform.Service) { diff --git a/selenosis.go b/selenosis.go index f463bdd..407fb4e 100644 --- a/selenosis.go +++ b/selenosis.go @@ -63,7 +63,7 @@ func New(logger *log.Logger, client platform.Platform, browsers *config.Browsers if quota, err = client.Quota().Get(); err != nil { quota, err = client.Quota().Create(currentTotal()) if err != nil { - logger.Errorf("failed to create quota resource: %v", err) + logger.Fatalf("failed to create quota resource: %v", err) } }