Skip to content

Commit

Permalink
Make search case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
andornaut committed Oct 2, 2020
1 parent 6c7a552 commit cbc7a0d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ var search = &cobra.Command{
Short: "Search through your secrets",
Args: cobra.MinimumNArgs(1),
RunE: func(c *cobra.Command, args []string) error {
// Internal whitespace is stripped by cobra, so search for any amount of internal whitespace.
// Internal whitespace is stripped by cobra, so we search for any amount of internal whitespace.
// Users can surround a single argument with quotation marks for more precise control of internal whitespace.
rs := strings.Join(args, "\\s+")
// Additionally, add a "case-insensitive" flag.
rs := "(?i)" + strings.Join(args, "\\s+")
r, err := regexp.Compile(rs)
if err != nil {
return fmt.Errorf("invalid regular expression \"%s\": %s", rs, err)
Expand Down

0 comments on commit cbc7a0d

Please sign in to comment.