From 3ed5a64cef52abedd2cc78765a97a7ccc632728e Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 23 Jul 2018 10:24:52 +0100 Subject: [PATCH] feat: case insensitive search by default #415 Former-commit-id: e39d951ceaac2a3c9b055b8661c17432d746f5d2 [formerly f6a93dfc39e6edec09f19228d9d8d6cb66fbdac4] [formerly 0cecdec65555f37fab1e8773f066928cf821f6b5 [formerly 43d489c19495df4c17f17e186b022e6de645925a]] Former-commit-id: 57fd7a80303a6044846a3e11fabe0c9402557052 [formerly 4ffe639c08a784a05d49ff615994bda5f700ec1a] Former-commit-id: 0db3b23185991ca9f0c0dc7e3f1eff5f4c2f7a77 --- http/websockets.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/http/websockets.go b/http/websockets.go index 27d63c26..e135d110 100644 --- a/http/websockets.go +++ b/http/websockets.go @@ -147,9 +147,9 @@ var ( type condition func(path string) bool type searchOptions struct { - CaseInsensitive bool - Conditions []condition - Terms []string + CaseSensitive bool + Conditions []condition + Terms []string } func extensionCondition(extension string) condition { @@ -181,9 +181,9 @@ func videoCondition(path string) bool { func parseSearch(value string) *searchOptions { opts := &searchOptions{ - CaseInsensitive: strings.Contains(value, "case:insensitive"), - Conditions: []condition{}, - Terms: []string{}, + CaseSensitive: strings.Contains(value, "case:sensitive"), + Conditions: []condition{}, + Terms: []string{}, } // removes the options from the value @@ -215,7 +215,7 @@ func parseSearch(value string) *searchOptions { } // If it's canse insensitive, put everything in lowercase. - if opts.CaseInsensitive { + if !opts.CaseSensitive { value = strings.ToLower(value) } @@ -276,7 +276,7 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) scope = filepath.Clean(scope) err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error { - if search.CaseInsensitive { + if !search.CaseSensitive { path = strings.ToLower(path) }