Merge pull request #4841 from mabashian/4768-search-keys-parentheses

Fixed regex that was breaking on parenthesis
This commit is contained in:
Michael Abashian 2017-01-20 10:05:52 -05:00 committed by GitHub
commit b2b18dd958
2 changed files with 3 additions and 1 deletions

View File

@ -1,7 +1,7 @@
export default [function() {
return {
splitSearchIntoTerms(searchString) {
return searchString.match(/(?:[^\s("')]+|"[^"]*"|'[^']*')+/g);
return searchString.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);
},
splitTermIntoParts(searchTerm) {
let breakOnColon = searchTerm.match(/(?:[^:"]+|"[^"]*")+/g);

View File

@ -25,6 +25,8 @@ describe('Service: SmartSearch', () => {
expect(SmartSearchService.splitSearchIntoTerms('name:\'foo bar\' description:\'bar foo\'')).toEqual(["name:\'foo bar\'", "description:\'bar foo\'"]);
expect(SmartSearchService.splitSearchIntoTerms('name:\"foo bar\" description:\'bar foo\'')).toEqual(["name:\"foo bar\"", "description:\'bar foo\'"]);
expect(SmartSearchService.splitSearchIntoTerms('name:\"foo bar\" foo')).toEqual(["name:\"foo bar\"", "foo"]);
expect(SmartSearchService.splitSearchIntoTerms('inventory:¯\_(ツ)_/¯')).toEqual(["inventory:¯\_(ツ)_/¯"]);
expect(SmartSearchService.splitSearchIntoTerms('inventory:¯\_(ツ)_/¯ inventory.name:¯\_(ツ)_/¯')).toEqual(["inventory:¯\_(ツ)_/¯", "inventory.name:¯\_(ツ)_/¯"]);
});
});