13
packages/lib/convertStrToList.ts
Normal file
13
packages/lib/convertStrToList.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export const convertStrToList = (str: string): string[] => {
|
||||
const splittedBreakLines = str.split('\n')
|
||||
const splittedCommas = str.split(',')
|
||||
const isPastingMultipleItems =
|
||||
str.length > 1 &&
|
||||
(splittedBreakLines.length >= 2 || splittedCommas.length >= 2)
|
||||
if (isPastingMultipleItems) {
|
||||
const values =
|
||||
splittedBreakLines.length >= 2 ? splittedBreakLines : splittedCommas
|
||||
return values.map((v) => v.trim())
|
||||
}
|
||||
return [str.trim()]
|
||||
}
|
||||
Reference in New Issue
Block a user