Skip to content

Commit

Permalink
Fix label filtering that contains the word "not"
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolemos committed Feb 2, 2020
1 parent ad58d3b commit 24a98e0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/core/src/helpers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ export function getSearchQueryTerms(

const result: Array<[string, boolean] | [string, string, boolean]> = []

const q = query.replace(/(^|\s)NOT(\s)/gi, '$1-').trim()
const q = query.trim()

// TODO: Fix regex with backslash
// ;(q.match(/("-?([^\\][^"])+")/g) || []).forEach((str, index) => {
Expand All @@ -588,10 +588,12 @@ export function getSearchQueryTerms(
// })
;(
q.match(
/(-?[a-zA-Z]+:"[^"]+")|(-?[a-zA-Z]+:[^ \n$]+)|(-?"[^"]+")|([^ $]+)/g,
/((-|NOT )?[a-zA-Z]+:"[^"]+")|((-|NOT )?[a-zA-Z]+:[^ \n$]+)|((-|NOT )?"[^"]+")|(-|NOT )?([^ $]+)/gi,
) || []
).forEach(queryItem => {
if (!queryItem) return
).forEach(_queryItem => {
if (!_queryItem) return

const queryItem = _queryItem.replace(/^(^|\s)NOT(\s)/gi, '$1-')

const [_keyOrValue, ..._values] =
queryItem[0] === '"' || (queryItem[0] === '-' && queryItem[1] === '"')
Expand Down

0 comments on commit 24a98e0

Please sign in to comment.