Skip to content

Commit

Permalink
refactor normalizeLowercase func
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed Jan 9, 2024
1 parent 1e58990 commit 7b9a6a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion v2/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (r *Runner) EnumerateMultipleDomainsWithCtx(ctx context.Context, reader io.
scanner := bufio.NewScanner(reader)
ip, _ := regexp.Compile(`^([0-9\.]+$)`)
for scanner.Scan() {
domain, err := sanitize(normalizeLowercase(scanner.Text()))
domain, err := normalizeLowercase(scanner.Text())
isIp := ip.MatchString(domain)
if errors.Is(err, ErrEmptyInput) || (r.options.ExcludeIps && isIp) {
continue
Expand Down
7 changes: 4 additions & 3 deletions v2/pkg/runner/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ func loadFromFile(file string) ([]string, error) {
}

func sanitize(data string) (string, error) {
data = strings.Trim(data, "\n\t\"' ")
data = strings.Trim(data, "\n\t\"'` ")
if data == "" {
return "", ErrEmptyInput
}
return data, nil
}

func normalizeLowercase(s string) string {
return strings.TrimSpace(strings.Trim(strings.TrimSpace(strings.ToLower(s)), string(quotes)))
func normalizeLowercase(s string) (string, error) {
data, err := sanitize(s)
return strings.ToLower(data), err
}

0 comments on commit 7b9a6a0

Please sign in to comment.