2021-08-08 23:42:10 +02:00
|
|
|
package generators
|
|
|
|
|
|
2022-11-06 21:24:23 +01:00
|
|
|
import stringsutil "github.com/projectdiscovery/utils/strings"
|
2021-08-08 23:42:10 +02:00
|
|
|
|
|
|
|
|
// 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 19:35:17 +05:30
|
|
|
key, _ := stringsutil.Before(sliceItem, sep)
|
|
|
|
|
value, _ := stringsutil.After(sliceItem, sep)
|
2021-08-08 23:42:10 +02:00
|
|
|
if key != "" {
|
|
|
|
|
m[key] = value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return m
|
|
|
|
|
}
|