aboutsummaryrefslogtreecommitdiff
path: root/v0/idsearcher/idsearcher.go
diff options
context:
space:
mode:
authorSteve Winslow <swinslow@gmail.com>2018-10-24 07:18:07 -0400
committerGitHub <noreply@github.com>2018-10-24 07:18:07 -0400
commit168a89233029649c77a452f35cc5fb36f669e5fb (patch)
treebb3a1fdef1321e6886097a12d91755f8de793531 /v0/idsearcher/idsearcher.go
parent511af5554f5d502ebebf41b3342f78c28dd7aa36 (diff)
parentd9270021e62bd0cc2419e319b410dc2c1e65940c (diff)
downloadspdx-tools-168a89233029649c77a452f35cc5fb36f669e5fb.tar.gz
Merge pull request #22 from swinslow/issue-21
Ignore case for operators when searching short-form IDs Signed-off-by: Steve Winslow <swinslow@gmail.com>
Diffstat (limited to 'v0/idsearcher/idsearcher.go')
-rw-r--r--v0/idsearcher/idsearcher.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/v0/idsearcher/idsearcher.go b/v0/idsearcher/idsearcher.go
index 4476dbe..0f8592a 100644
--- a/v0/idsearcher/idsearcher.go
+++ b/v0/idsearcher/idsearcher.go
@@ -204,19 +204,18 @@ func getIndividualLicenses(lic string) []string {
lic = strings.Replace(lic, "(", " ", -1)
lic = strings.Replace(lic, ")", " ", -1)
- // also replace combination words with spaces
- lic = strings.Replace(lic, " AND ", " ", -1)
- lic = strings.Replace(lic, " OR ", " ", -1)
- lic = strings.Replace(lic, " WITH ", " ", -1)
-
// now, split by spaces, trim, and add to slice
licElements := strings.Split(lic, " ")
lics := []string{}
for _, elt := range licElements {
elt := strings.TrimSpace(elt)
- if elt != "" {
- lics = append(lics, elt)
+ // don't add if empty or if case-insensitive operator
+ if elt == "" || strings.EqualFold(elt, "AND") ||
+ strings.EqualFold(elt, "OR") || strings.EqualFold(elt, "WITH") {
+ continue
}
+
+ lics = append(lics, elt)
}
// sort before returning