From bdf028646f65ae68d7accf5ddc8fd849852f8544 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 22 Jun 2017 18:53:24 +0200 Subject: [PATCH] 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. --- src/demo-app/autocomplete/autocomplete-demo.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/demo-app/autocomplete/autocomplete-demo.ts b/src/demo-app/autocomplete/autocomplete-demo.ts index 00fbeeb1a15..7fa011eeadf 100644 --- a/src/demo-app/autocomplete/autocomplete-demo.ts +++ b/src/demo-app/autocomplete/autocomplete-demo.ts @@ -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; + } }