Files
js/utils/string.ts
T
Jonas DanielsandElasticBottle 33e7a9e729 feat(api): add redirectUrls field to ApiKey (#1755)
* fix(api): add redirectUrls field to ApiKey

* test: add redirectUrls validation test

* feat: display redirecrURIs on dashboard

* chore: update helper text for redirectURIs

---------

Co-authored-by: ElasticBottle <[email protected]>
2023-10-11 20:18:53 +00:00

19 lines
459 B
TypeScript

export const toArrFromList = (str: string, allowTrailingSlash = false) => {
if (!str) {
return [];
}
// split by comma or new-line character
// trim white spaces
// remove trailing slash
// remove empty elements
return str
.split(/[\n,]/)
.map((v) => (allowTrailingSlash ? v.trim() : v.trim().replace(/\/$/, "")))
.filter((v) => v.length > 0);
};
export const fromArrayToList = (arr: string[]) => {
return arr.join(", ");
};