Files
js/utils/string.ts
T
Tair Asim 63a0a7089b chore: api keys polish (#1477)
* chore: api keys polish

- validate key name uniqueness
- fix enter on submit refreshing page
- polish copy

* fixes

* fix unused

* copy

* fix test

* add unrestricted access checkbox

* update copy

* add doc link

* remove key name validation

* trim trailing slash
2023-08-03 21:27:24 +00:00

19 lines
397 B
TypeScript

export const toArrFromList = (str: string) => {
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) => v.trim().replace(/\/$/, ""))
.filter((v) => v.length > 0);
};
export const fromArrayToList = (arr: string[]) => {
return arr.join(", ");
};