nuclei/pkg/protocols/common/generators/slice.go

17 lines
469 B
Go
Raw Normal View History

package generators
import stringsutil "github.com/projectdiscovery/utils/strings"
// SliceToMap converts a slice of strings to map of string splitting each item at sep as "key sep value"
func SliceToMap(s []string, sep string) map[string]interface{} {
m := make(map[string]interface{})
for _, sliceItem := range s {
2022-08-27 14:05:17 +00:00
key, _ := stringsutil.Before(sliceItem, sep)
value, _ := stringsutil.After(sliceItem, sep)
if key != "" {
m[key] = value
}
}
return m
}