mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
add tests around MatchNamedCaptureGroups + rename
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
@@ -21,7 +21,7 @@ func parseLicensesFromCopyright(reader io.Reader) []string {
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
|
||||
matchesByGroup := internal.MatchCaptureGroups(licensePattern, line)
|
||||
matchesByGroup := internal.MatchNamedCaptureGroups(licensePattern, line)
|
||||
if len(matchesByGroup) > 0 {
|
||||
candidate, ok := matchesByGroup["license"]
|
||||
if !ok {
|
||||
|
||||
@@ -145,7 +145,7 @@ func extractAllFields(reader *bufio.Reader) (map[string]interface{}, error) {
|
||||
// of the "<name>" form, then return name and nil
|
||||
func extractSourceVersion(source string) (string, string) {
|
||||
// special handling for the Source field since it has formatted data
|
||||
match := internal.MatchCaptureGroups(sourceRegexp, source)
|
||||
match := internal.MatchNamedCaptureGroups(sourceRegexp, source)
|
||||
return match["name"], match["version"]
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ func (a *Author) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
} else {
|
||||
// parse out "name <email> (url)" into an Author struct
|
||||
fields = internal.MatchCaptureGroups(authorPattern, authorStr)
|
||||
fields = internal.MatchNamedCaptureGroups(authorPattern, authorStr)
|
||||
}
|
||||
|
||||
// translate the map into a structure
|
||||
|
||||
@@ -77,7 +77,7 @@ func parseGemSpecEntries(_ string, reader io.Reader) ([]pkg.Package, error) {
|
||||
}
|
||||
|
||||
for field, pattern := range patterns {
|
||||
matchMap := internal.MatchCaptureGroups(pattern, sanitizedLine)
|
||||
matchMap := internal.MatchNamedCaptureGroups(pattern, sanitizedLine)
|
||||
if value := matchMap[field]; value != "" {
|
||||
if postProcessor := postProcessors[field]; postProcessor != nil {
|
||||
fields[field] = postProcessor(value)
|
||||
|
||||
Reference in New Issue
Block a user