From 43d489c19495df4c17f17e186b022e6de645925a 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 --- 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) }