From 5d866a74e308f559d2ef7e79cb47908147f2f553 Mon Sep 17 00:00:00 2001 From: Seednode Date: Mon, 25 Sep 2023 11:15:49 -0500 Subject: [PATCH] Add option for case-sensitive filters --- cmd/root.go | 4 +++- cmd/uri.go | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 791bce8..d102dea 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -11,7 +11,7 @@ import ( ) const ( - ReleaseVersion string = "0.91.0" + ReleaseVersion string = "0.92.0" ) var ( @@ -20,6 +20,7 @@ var ( Bind string Cache bool CacheFile string + CaseSensitive bool Code bool CodeTheme string ExitOnError bool @@ -71,6 +72,7 @@ func init() { 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().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().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") diff --git a/cmd/uri.go b/cmd/uri.go index 8706496..9988a67 100644 --- a/cmd/uri.go +++ b/cmd/uri.go @@ -47,8 +47,11 @@ func splitQueryParams(query string, regexes *regexes) []string { params := strings.Split(query, ",") 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])) + case regexes.alphanumeric.MatchString(params[i]): + results = append(results, params[i]) } }