fix for args not splitting correctly with empty values

This commit is contained in:
Nikhil Nandagopal 2020-11-05 15:46:38 +05:30
parent e99a94df87
commit 39331d95b2

View File

@ -106,13 +106,21 @@ const JSToString = (js: string): string => {
const argsStringToArray = (funcArgs: string): string[] => {
const argsplitMatches = [...funcArgs.matchAll(FUNC_ARGS_REGEX)];
return argsplitMatches
.map(match => {
return match[0];
})
.filter(arg => {
return arg !== "";
});
const arr: string[] = [];
let isPrevUndefined = true;
argsplitMatches.forEach(match => {
const matchVal = match[0];
if (!matchVal || matchVal === "") {
if (isPrevUndefined) {
arr.push(matchVal);
}
isPrevUndefined = true;
} else {
isPrevUndefined = false;
arr.push(matchVal);
}
});
return arr;
};
const textSetter = (