diff --git a/awx/ui/client/src/shared/smart-search/smart-search.service.js b/awx/ui/client/src/shared/smart-search/smart-search.service.js index ffaa95bc8c..8e7b57271d 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.service.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.service.js @@ -14,12 +14,8 @@ export default [function() { let groups = []; let quoted; - if (!searchString.includes(' ')) { - return this.splitSearchIntoTerms(this.encode(searchString)); - } - searchString.split(' ').forEach(substring => { - if (substring.includes(':"')) { + if (/:"/g.test(substring)) { if (/"$/.test(substring)) { groups.push(this.encode(substring)); } else { @@ -28,7 +24,7 @@ export default [function() { } else if (quoted) { quoted += ` ${substring}`; - if (substring.includes('"')) { + if (/"/g.test(substring)) { groups.push(this.encode(quoted)); quoted = undefined; } diff --git a/awx/ui/tests/spec/smart-search/smart-search.service-test.js b/awx/ui/tests/spec/smart-search/smart-search.service-test.js index 6c2ad05f09..cd7aef4848 100644 --- a/awx/ui/tests/spec/smart-search/smart-search.service-test.js +++ b/awx/ui/tests/spec/smart-search/smart-search.service-test.js @@ -54,7 +54,7 @@ describe('Service: SmartSearch', () => { expect(SmartSearchService.splitFilterIntoTerms('name:"foo bar" a b c')).toEqual(["name:%22foo%20bar%22", 'a', 'b', 'c']); expect(SmartSearchService.splitFilterIntoTerms('name:"1"')).toEqual(["name:%221%22"]); expect(SmartSearchService.splitFilterIntoTerms('name:1')).toEqual(["name:1"]); - expect(SmartSearchService.splitFilterIntoTerms(`name:"foo ba'r" a b c`)).toEqual(["name:%22foo%20ba%27r%22", 'a', 'b', 'c']); + expect(SmartSearchService.splitFilterIntoTerms('name:"foo ba\'r" a b c')).toEqual(["name:%22foo%20ba%27r%22", 'a', 'b', 'c']); expect(SmartSearchService.splitFilterIntoTerms('name:"foobar" other:"barbaz"')).toEqual(["name:%22foobar%22", "other:%22barbaz%22"]); expect(SmartSearchService.splitFilterIntoTerms('name:"foobar" other:"bar baz"')).toEqual(["name:%22foobar%22", "other:%22bar%20baz%22"]); });