Skip to content

Commit c7f8fa0

Browse files
committed
abstract placeholder
1 parent ee5d621 commit c7f8fa0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/util/parser.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ export const collapseSpaces = (input: string) => input.replace(/\s+/g, ' ');
22
export const stripNewLines = (input: string) =>
33
input.replace(/\r\n|\n|\r/g, ' ');
44

5+
const COMMA_PLACEHOLDER = '<COMMA>';
6+
57
export const generateSchema = (argsDefinition: string) =>
68
argsDefinition
79
.replace(/\(([^()]+)\)/g, (match) => {
810
// Replace commas with placeholder inside the parentheses content
9-
return match.replace(/,/g, '<COMMA>');
11+
return match.replace(/,/g, COMMA_PLACEHOLDER);
1012
})
1113
.split(',')
12-
.map((item) => item.replace(/\s*/g, '').replace(/<COMMA>/g, ','))
14+
.map((item) =>
15+
item.replace(/\s*/g, '').replace(new RegExp(COMMA_PLACEHOLDER, 'g'), ','),
16+
)
1317
.filter((item) => item !== '');
1418

1519
export const stripComments = (code: string) => {

0 commit comments

Comments
 (0)