add tests around MatchNamedCaptureGroups + rename

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2021-04-12 17:08:50 -04:00
parent 66ebe49a04
commit 5743e32e02
7 changed files with 113 additions and 19 deletions
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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"]
}