Archived
1
0

Fix other incorrect usages of split

This commit is contained in:
Asher
2019-10-28 14:03:13 -05:00
parent 83ff31b620
commit a89d83cbba
3 changed files with 19 additions and 10 deletions

10
src/common/util.ts Normal file
View File

@ -0,0 +1,10 @@
/**
* Split a string up to the delimiter. If the delimiter doesn't exist the first
* item will have all the text and the second item will be an empty string.
*/
export const split = (str: string, delimiter: string): [string, string] => {
const index = str.indexOf(delimiter);
return index !== -1
? [str.substring(0, index).trim(), str.substring(index + 1)]
: [str, ""];
};