Add option for case-sensitive filters

This commit is contained in:
Seednode 2023-09-25 11:15:49 -05:00
parent e4ade4532b
commit 5d866a74e3
2 changed files with 7 additions and 2 deletions

View File

@ -11,7 +11,7 @@ import (
) )
const ( const (
ReleaseVersion string = "0.91.0" ReleaseVersion string = "0.92.0"
) )
var ( var (
@ -20,6 +20,7 @@ var (
Bind string Bind string
Cache bool Cache bool
CacheFile string CacheFile string
CaseSensitive bool
Code bool Code bool
CodeTheme string CodeTheme string
ExitOnError bool ExitOnError bool
@ -71,6 +72,7 @@ func init() {
rootCmd.Flags().StringVarP(&Bind, "bind", "b", "0.0.0.0", "address to bind to") rootCmd.Flags().StringVarP(&Bind, "bind", "b", "0.0.0.0", "address to bind to")
rootCmd.Flags().BoolVarP(&Cache, "cache", "c", false, "generate directory cache at startup") rootCmd.Flags().BoolVarP(&Cache, "cache", "c", false, "generate directory cache at startup")
rootCmd.Flags().StringVar(&CacheFile, "cache-file", "", "path to optional persistent cache file") rootCmd.Flags().StringVar(&CacheFile, "cache-file", "", "path to optional persistent cache file")
rootCmd.Flags().BoolVar(&CaseSensitive, "case-sensitive", false, "use case-sensitive matching for filters")
rootCmd.Flags().BoolVar(&Code, "code", false, "enable support for source code files") rootCmd.Flags().BoolVar(&Code, "code", false, "enable support for source code files")
rootCmd.Flags().StringVar(&CodeTheme, "code-theme", "solarized-dark256", "theme for source code syntax highlighting") rootCmd.Flags().StringVar(&CodeTheme, "code-theme", "solarized-dark256", "theme for source code syntax highlighting")
rootCmd.Flags().BoolVar(&ExitOnError, "exit-on-error", false, "shut down webserver on error, instead of just printing the error") rootCmd.Flags().BoolVar(&ExitOnError, "exit-on-error", false, "shut down webserver on error, instead of just printing the error")

View File

@ -47,8 +47,11 @@ func splitQueryParams(query string, regexes *regexes) []string {
params := strings.Split(query, ",") params := strings.Split(query, ",")
for i := 0; i < len(params); i++ { for i := 0; i < len(params); i++ {
if regexes.alphanumeric.MatchString(params[i]) { switch {
case regexes.alphanumeric.MatchString(params[i]) && CaseSensitive:
results = append(results, strings.ToLower(params[i])) results = append(results, strings.ToLower(params[i]))
case regexes.alphanumeric.MatchString(params[i]):
results = append(results, params[i])
} }
} }