-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(patients): fixes search when using special characters #2012
Conversation
Reason field on new appointment screen no longer a required field. Line 21, Label element now takes isRequired attr from interface Props. fix HospitalRun#1997
Previously added a listing for yarn in the dependencies in package.json. This commit undoes that. re |
Added a test case to test if the Label receives the isRequired prop on required fields re HospitalRun#2003
Changed const expectedValue to const expectedRequired, named for prop isRequired re HospitalRun#2003
Added a step to take the search string and remove all non-letter/whitespace characters. Line 16 and 22 fix HospitalRun#1999
Added a step to remove all non-alphabetical and whitespace characters from search string regex fix HospitalRun#1999
Removed special chars that interfered with RegExp in search strings re HospitalRun#1999
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/hospitalrun/hospitalrun-frontend/6fxtwuuth |
src/clients/db/PatientRepository.ts
Outdated
@@ -13,12 +13,13 @@ export class PatientRepository extends Repository<Patient> { | |||
} | |||
|
|||
async search(text: string): Promise<Patient[]> { | |||
const cleanText = text.replace(/[\\[()?*]+/g, '') |
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.
I also checked with String {1}
.
SyntaxError: Invalid regular expression: /{1}/: Nothing to repeat.
Can you please handle this case as well?
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.
I think that we should also remove ]
, and {
, and }
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.
Ok, will do.
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.
I think that we need to remove all valid regex chars. Is there any lib out there that can help us to not forget any char?
Added escapeStringRegexp package to escape special chars in search string for p fix HospitalRun#1999
Fixes #1999.
Search string in patient search field is now cleaned of any breaking special characters.
Removes any number of occurrences of these chars:
[*?()