mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Replace use of string.includes due lack of browser support
This commit is contained in:
parent
eab3cb8efd
commit
dd62e8ce92
@ -14,12 +14,8 @@ export default [function() {
|
|||||||
let groups = [];
|
let groups = [];
|
||||||
let quoted;
|
let quoted;
|
||||||
|
|
||||||
if (!searchString.includes(' ')) {
|
|
||||||
return this.splitSearchIntoTerms(this.encode(searchString));
|
|
||||||
}
|
|
||||||
|
|
||||||
searchString.split(' ').forEach(substring => {
|
searchString.split(' ').forEach(substring => {
|
||||||
if (substring.includes(':"')) {
|
if (/:"/g.test(substring)) {
|
||||||
if (/"$/.test(substring)) {
|
if (/"$/.test(substring)) {
|
||||||
groups.push(this.encode(substring));
|
groups.push(this.encode(substring));
|
||||||
} else {
|
} else {
|
||||||
@ -28,7 +24,7 @@ export default [function() {
|
|||||||
} else if (quoted) {
|
} else if (quoted) {
|
||||||
quoted += ` ${substring}`;
|
quoted += ` ${substring}`;
|
||||||
|
|
||||||
if (substring.includes('"')) {
|
if (/"/g.test(substring)) {
|
||||||
groups.push(this.encode(quoted));
|
groups.push(this.encode(quoted));
|
||||||
quoted = undefined;
|
quoted = undefined;
|
||||||
}
|
}
|
||||||
|
@ -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:"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:%221%22"]);
|
||||||
expect(SmartSearchService.splitFilterIntoTerms('name:1')).toEqual(["name:1"]);
|
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:"barbaz"')).toEqual(["name:%22foobar%22", "other:%22barbaz%22"]);
|
||||||
expect(SmartSearchService.splitFilterIntoTerms('name:"foobar" other:"bar baz"')).toEqual(["name:%22foobar%22", "other:%22bar%20baz%22"]);
|
expect(SmartSearchService.splitFilterIntoTerms('name:"foobar" other:"bar baz"')).toEqual(["name:%22foobar%22", "other:%22bar%20baz%22"]);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user