Skip to content

Commit

Permalink
Cascader: escape special characters for regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
jikkai committed Aug 6, 2018
1 parent 8de71d0 commit 63f38e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/cascader/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ export default {
}
let filteredFlatOptions = flatOptions.filter(optionsStack => {
return optionsStack.some(option => new RegExp(value, 'i').test(option[this.labelKey]));
const escapedValue = value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
return optionsStack.some(option => new RegExp(escapedValue, 'i')
.test(option[this.labelKey]));
});
if (filteredFlatOptions.length > 0) {
Expand Down

0 comments on commit 63f38e9

Please sign in to comment.