Merge pull request #97 from aykhans/fix/nil-url
All checks were successful
golangci-lint / lint (push) Successful in 58s

🐛 Fix nil URL referance
This commit is contained in:
Aykhan Shahsuvarov 2025-03-20 03:20:33 +04:00 committed by GitHub
commit 3cd72855e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,24 +132,26 @@ func (c *Config) Validate() []error {
var errs []error
if utils.IsNilOrZero(c.URL) {
errs = append(errs, errors.New("request URL is required"))
}
if c.URL.Scheme == "" {
c.URL.Scheme = "http"
}
if c.URL.Scheme != "http" && c.URL.Scheme != "https" {
errs = append(errs, errors.New("request URL scheme must be http or https"))
}
urlParams := types.Params{}
for key, values := range c.URL.Query() {
for _, value := range values {
urlParams = append(urlParams, types.KeyValue[string, []string]{
Key: key,
Value: []string{value},
})
} else {
if c.URL.Scheme == "" {
c.URL.Scheme = "http"
}
if c.URL.Scheme != "http" && c.URL.Scheme != "https" {
errs = append(errs, errors.New("request URL scheme must be http or https"))
}
urlParams := types.Params{}
for key, values := range c.URL.Query() {
for _, value := range values {
urlParams = append(urlParams, types.KeyValue[string, []string]{
Key: key,
Value: []string{value},
})
}
}
c.Params = append(urlParams, c.Params...)
c.URL.RawQuery = ""
}
c.Params = append(urlParams, c.Params...)
c.URL.RawQuery = ""
if utils.IsNilOrZero(c.Method) {
errs = append(errs, errors.New("request method is required"))