-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement feature trim function to the search inputs on the sco…
…re (#2384) * feat: implement feature trim funtcion to the search inputs on the score * fix: lint errors * fix: add value check for type string[] * fix: remove string type for filters on the score * fix: add trim for query params * fix: add string type for optionalQueryString * fix: add returned value by string[] * fix: returnd valeu * fix: array serialization * fix: add trim function for each element in array
- Loading branch information
Showing
3 changed files
with
20 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
export function optionalQueryString(value: string | undefined) { | ||
return value ? String(value) : undefined; | ||
export function optionalQueryString(value: string | string[] | undefined) { | ||
if (Array.isArray(value)) { | ||
const trimmedElements = value.map(elem => elem.trim()).join(','); | ||
if (trimmedElements !== '') { | ||
return trimmedElements; | ||
} | ||
} else if (typeof value === 'string') { | ||
return String(value).trim(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters