Skip to content

Commit 8759bf4

Browse files
authored
GH-612: core search can match Platform#ID too. (#615)
When matching against a Platform#ID, the match must be a case-insensitive exact match. Closes #612. Signed-off-by: Akos Kitta <[email protected]>
1 parent fbcd87f commit 8759bf4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: commands/core/search.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ func match(line, searchArgs string) bool {
2929
return strings.Contains(strings.ToLower(line), strings.ToLower(searchArgs))
3030
}
3131

32+
func exactMatch(line, searchArgs string) bool {
33+
return strings.Compare(strings.ToLower(line), strings.ToLower(searchArgs)) == 0
34+
}
35+
3236
// PlatformSearch FIXMEDOC
3337
func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc.PlatformSearchResp, error) {
3438
pm := commands.GetPackageManager(instanceID)
@@ -55,7 +59,7 @@ func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc
5559
}
5660

5761
// platform has a valid release, check if it matches the search arguments
58-
if match(platform.Name, searchArgs) || match(platform.Architecture, searchArgs) {
62+
if match(platform.Name, searchArgs) || match(platform.Architecture, searchArgs) || exactMatch(platform.String(), searchArgs) {
5963
if allVersions {
6064
res = append(res, platform.GetAllReleases()...)
6165
} else {

0 commit comments

Comments
 (0)