chore: fix error when searching for special characters in the autocomplete demo (#5213)

Fixes regex special characters causing the autocomplete in the demo app to throw.

Relates to #3373.
This commit is contained in:
Kristiyan Kostadinov
2017-06-22 18:53:24 +02:00
committed by Jeremy Elbourn
parent 0ea2533b80
commit bdf028646f
@@ -88,8 +88,11 @@ export class AutocompleteDemo {
}
filterStates(val: string) {
return val ? this.states.filter(s => new RegExp(`^${val}`, 'gi').test(s.name))
: this.states;
}
if (val) {
const filterValue = val.toLowerCase();
return this.states.filter(state => state.name.toLowerCase().startsWith(filterValue));
}
return this.states;
}
}