From 2dd7f62adfea1d99a241769b565200f7de084186 Mon Sep 17 00:00:00 2001 From: kapishmalik Date: Sun, 7 Apr 2024 11:39:00 +0530 Subject: [PATCH] review comment change --- core/action/action.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/action/action.go b/core/action/action.go index 68d671756..3416a0862 100644 --- a/core/action/action.go +++ b/core/action/action.go @@ -6,6 +6,7 @@ import ( "errors" "io/ioutil" "net/http" + "net/url" "os" "os/exec" "path" @@ -49,7 +50,7 @@ func NewRemoteAction(actionName, host string, delayInMs int) (*Action, error) { return nil, errors.New("empty action name passed") } - if !hasHttpPrefix(host) { + if !isValidURL(host) { return nil, errors.New("remote host is invalid") } @@ -183,6 +184,10 @@ func (action *Action) Execute(pair *models.RequestResponsePair) error { return nil } -func hasHttpPrefix(host string) bool { - return strings.HasPrefix(host, "http") || strings.HasPrefix(host, "https") +func isValidURL(host string) bool { + + if _, err := url.ParseRequestURI(host); err == nil { + return true + } + return false }