Skip to content

Commit

Permalink
Fix: avoid to modify the original url request params (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx authored Dec 6, 2021
1 parent 95c90ec commit 673310f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions metricbeat/mb/parse/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (b URLHostParserBuilder) Build() mb.HostParser {
return func(module mb.Module, host string) (mb.HostData, error) {
conf := map[string]interface{}{}
err := module.UnpackConfig(conf)
var QueryParams string
if err != nil {
return mb.HostData{}, err
}
Expand All @@ -57,7 +58,7 @@ func (b URLHostParserBuilder) Build() mb.HostParser {
return mb.HostData{}, errors.Errorf("'query' config for module %v is not a map", module.Name())
}

b.QueryParams = mb.QueryParams(queryMap).String()
QueryParams = mb.QueryParams(queryMap).String()
}

var user, pass, path, basePath string
Expand Down Expand Up @@ -104,7 +105,7 @@ func (b URLHostParserBuilder) Build() mb.HostParser {
// Combine paths and normalize
fullPath := strings.Trim(p.Join(basePath, path), "/")

return ParseURL(host, b.DefaultScheme, user, pass, fullPath, b.QueryParams)
return ParseURL(host, b.DefaultScheme, user, pass, fullPath, QueryParams)
}
}

Expand Down

0 comments on commit 673310f

Please sign in to comment.