Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/common/generators/slice.go
2072 views
1
package generators
2
3
import stringsutil "github.com/projectdiscovery/utils/strings"
4
5
// SliceToMap converts a slice of strings to map of string splitting each item at sep as "key sep value"
6
func SliceToMap(s []string, sep string) map[string]interface{} {
7
m := make(map[string]interface{})
8
for _, sliceItem := range s {
9
key, _ := stringsutil.Before(sliceItem, sep)
10
value, _ := stringsutil.After(sliceItem, sep)
11
if key != "" {
12
m[key] = value
13
}
14
}
15
return m
16
}
17
18