mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-12-01 12:13:00 +03:00
using new line as split token for data from file
This commit is contained in:
parent
7a59d6702b
commit
6804cda5e4
@ -12,7 +12,7 @@ func (c *CustomList) String() string {
|
||||
|
||||
// Set a new global header
|
||||
func (c *CustomList) Set(value string) error {
|
||||
values := fileutil.LoadCidrsFromSliceOrFile(value)
|
||||
values := fileutil.LoadCidrsFromSliceOrFile(value, ",")
|
||||
*c = append(*c, values...)
|
||||
return nil
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ func FileNameIsGlob(pattern string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func LoadCidrsFromSliceOrFile(option string) (networkList []string) {
|
||||
items := stringz.SplitByCharAndTrimSpace(option, ",")
|
||||
func LoadCidrsFromSliceOrFile(option string, splitchar string) (networkList []string) {
|
||||
items := stringz.SplitByCharAndTrimSpace(option, splitchar)
|
||||
for _, item := range items {
|
||||
// ip
|
||||
if net.ParseIP(item) != nil {
|
||||
@ -86,7 +86,7 @@ func LoadCidrsFromSliceOrFile(option string) (networkList []string) {
|
||||
networkList = append(networkList, item)
|
||||
} else if fileutil.FileExists(item) {
|
||||
if filedata, err := ioutil.ReadFile(item); err == nil && len(filedata) > 0 {
|
||||
networkList = append(networkList, LoadCidrsFromSliceOrFile(string(filedata))...)
|
||||
networkList = append(networkList, LoadCidrsFromSliceOrFile(string(filedata), "\n")...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user