-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes invalid regexp scenario #1081
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,11 +107,15 @@ class SchemaList extends PageComponent<{}> { | |
if (api.schemaOverviewIsConfigured == false) return renderNotConfigured(); | ||
if (api.schemaSubjects === undefined) return DefaultSkeleton; // request in progress | ||
|
||
const quickSearchRegExp = new RegExp(uiSettings.schemaList.quickSearch, 'i') | ||
|
||
const filteredSubjects = api.schemaSubjects | ||
.filter(x => uiSettings.schemaList.showSoftDeleted || (!uiSettings.schemaList.showSoftDeleted && !x.isSoftDeleted)) | ||
.filter(x => x.name.toLowerCase().match(quickSearchRegExp)); | ||
let filteredSubjects = api.schemaSubjects | ||
|
||
try { | ||
const quickSearchRegExp = new RegExp(uiSettings.schemaList.quickSearch, 'i') | ||
filteredSubjects = filteredSubjects.filter(x => uiSettings.schemaList.showSoftDeleted || (!uiSettings.schemaList.showSoftDeleted && !x.isSoftDeleted)) | ||
.filter(x => x.name.toLowerCase().match(quickSearchRegExp)); | ||
} catch (e) { | ||
console.warn('Invalid expression') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we should handle or rethrow the error or capture the exception. Maybe we should also check that the regexp should run, if there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @malinskibeniamin based on what I found there is no other way to check whether regexp is valid other than trying to compose it and catch with an exception. IF it's valid, we filter on it, if it's not valid, we keep the original array. |
||
} | ||
|
||
return ( | ||
<PageContent key="b"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint?