Skip to content

Commit

Permalink
review comment change
Browse files Browse the repository at this point in the history
  • Loading branch information
kapishmalik committed Apr 7, 2024
1 parent a63fb91 commit 2dd7f62
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"io/ioutil"
"net/http"
"net/url"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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
}

0 comments on commit 2dd7f62

Please sign in to comment.