github.com/projectdiscovery/nuclei/v2@v2.9.15/pkg/protocols/common/generators/slice.go (about)

     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  }