From 01f27fa049f5c458e241c5401154292edafac756 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Thu, 12 Mar 2020 15:12:39 +0100 Subject: [PATCH] GH-612: `core search` can match Platform#ID too. When matching against a Platform#ID, the match must be a case-insensitive exact match. Closes #612. Signed-off-by: Akos Kitta --- commands/core/search.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/core/search.go b/commands/core/search.go index 914ff5b12e8..1fa2fb8c360 100644 --- a/commands/core/search.go +++ b/commands/core/search.go @@ -29,6 +29,10 @@ func match(line, searchArgs string) bool { return strings.Contains(strings.ToLower(line), strings.ToLower(searchArgs)) } +func exactMatch(line, searchArgs string) bool { + return strings.Compare(strings.ToLower(line), strings.ToLower(searchArgs)) == 0 +} + // PlatformSearch FIXMEDOC func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc.PlatformSearchResp, error) { pm := commands.GetPackageManager(instanceID) @@ -55,7 +59,7 @@ func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc } // platform has a valid release, check if it matches the search arguments - if match(platform.Name, searchArgs) || match(platform.Architecture, searchArgs) { + if match(platform.Name, searchArgs) || match(platform.Architecture, searchArgs) || exactMatch(platform.String(), searchArgs) { if allVersions { res = append(res, platform.GetAllReleases()...) } else {