Skip to content

Commit 35af06d

Browse files
authored
Merge pull request #396 from PDOK/fix-character-replacement
fix(search): replace discarded characters with space instead of empty string
2 parents 8f7c67f + cdb5616 commit 35af06d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/ogc/features_search/url.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const (
2525
var (
2626
deepObjectParamRegex = regexp.MustCompile(`\w+\[\w+\]`)
2727

28-
// matches & (AND), | (OR), ! (NOT), and <-> (FOLLOWED BY).
28+
// matches `&` (AND), `|` (OR), `!` (NOT), and `<->` (FOLLOWED BY).
2929
searchOperatorsRegex = regexp.MustCompile(`&|\||!|<->`)
30-
// matches ' (apostrophe), ( (left parenthesis), and ) (right parenthesis).
30+
// matches `'` (apostrophe), `(` (left parenthesis), and `)` (right parenthesis).
3131
searchDiscardCharactersRegex = regexp.MustCompile(`'|\(|\)`)
3232

3333
searchKnownParams = map[string]struct{}{
@@ -90,7 +90,7 @@ func parseCollections(query url.Values) (d.CollectionsWithParams, error) {
9090
}
9191

9292
func parseSearchTerms(query url.Values) (string, error) {
93-
searchTerms := searchDiscardCharactersRegex.ReplaceAllLiteralString(strings.TrimSpace(strings.ToLower(query.Get(queryParam))), "")
93+
searchTerms := searchDiscardCharactersRegex.ReplaceAllLiteralString(strings.TrimSpace(strings.ToLower(query.Get(queryParam))), " ")
9494
if searchTerms == "" {
9595
return "", fmt.Errorf("no search terms provided, '%s' query parameter is required", queryParam)
9696
}

0 commit comments

Comments
 (0)