Skip to content

Commit

Permalink
Optimized search, fixed filters
Browse files Browse the repository at this point in the history
Signed-off-by: xplshn <xplshn@murena.io>
  • Loading branch information
xplshn committed Dec 7, 2024
1 parent 885e0c0 commit 22f7456
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions findURL.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ func findURL(config *Config, binaryNames []string, verbosityLevel Verbosity, met
// Check if binaryName is a valid URL
parsedURL, err := url.ParseRequestURI(binaryName)
if err == nil && parsedURL.Scheme != "" && parsedURL.Host != "" {
// If it's a valid URL, return it with the checksum set to "!no_warn"
// If it's a valid URL, return it with the checksum set to "null"
if verbosityLevel >= extraVerbose {
fmt.Printf("\033[2K\rFound \"%s\" is already a valid URL", binaryName)
}
foundURLs = append(foundURLs, binaryName)
foundB3sum = append(foundB3sum, "!no_warn")
foundB3sum = append(foundB3sum, "null")
continue
}

Expand Down
13 changes: 13 additions & 0 deletions fsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,22 @@ func fSearch(config *Config, searchTerm string, metadata map[string]interface{})
}
}

// Extract real names for filtering
allBinaryNames := make([]string, len(binaries))
for i, binary := range binaries {
allBinaryNames[i] = binary.RealName
}

// Filter binaries using the filterBinaries function from list.go
filteredBinaryNames := filterBinaries(allBinaryNames)

// Filter binaries based on the search term and architecture
searchResults := make([]string, 0)
for _, binary := range binaries {
if !contains(filteredBinaryNames, binary.RealName) || binary.Description == "" {
continue
}

if strings.Contains(strings.ToLower(binary.RealName), strings.ToLower(searchTerm)) ||
strings.Contains(strings.ToLower(binary.Description), strings.ToLower(searchTerm)) {
entry := fmt.Sprintf("%s - %s", binary.RealName, binary.Description)
Expand Down

0 comments on commit 22f7456

Please sign in to comment.