-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMTP: WIP - Non-working attempt at implementing search feature (index…
…es are not preserved)
- Loading branch information
Lucas Hinderberger
committed
Jun 24, 2024
1 parent
132505f
commit 9b1f5b2
Showing
4 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package smtp | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
) | ||
|
||
func searchByHeaderCommon(headerIdxList []map[string][]string, re *regexp.Regexp) []int { | ||
result := make([]int, 0, len(headerIdxList)) | ||
|
||
for idx, headers := range headerIdxList { | ||
if anyHeaderMatches(headers, re) { | ||
result = append(result, idx) | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
func anyHeaderMatches(headers map[string][]string, re *regexp.Regexp) bool { | ||
for k, v := range headers { | ||
header := fmt.Sprintf("%s: %s", k, v) | ||
if re.MatchString(header) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters