@aimeloic/monkey-tester 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/htmlTemplate.js +270 -1038
  2. package/index.js +17 -17
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -19,9 +19,7 @@ export function endtesterExpress() {
19
19
  const lower = field.toLowerCase();
20
20
 
21
21
  if (lower.includes('email')) return 'email';
22
-
23
22
  if (lower.includes('password')) return 'password';
24
-
25
23
  if (lower.includes('date')) return 'date';
26
24
 
27
25
  if (
@@ -56,21 +54,25 @@ export function endtesterExpress() {
56
54
  }
57
55
 
58
56
  // =========================
59
- // Extract req.body fields
57
+ // Extract req.body fields (FIXED MULTI-LINE)
60
58
  // =========================
61
59
  function extractBodyFields(handler) {
62
60
  try {
63
61
  const source = handler.toString();
64
62
 
65
- const regex =
66
- /(const|let|var)\s*\{\s*([^}]+)\s*\}\s*=\s*req\.body/g;
67
-
63
+ // FIXED: The 's' flag allows matching across multiple lines (\n)
64
+ const regex = /(const|let|var)\s*\{\s*([^}]+)\s*\}\s*=\s*req\.body/gs;
68
65
  const matches = [...source.matchAll(regex)];
69
-
70
66
  const fields = [];
71
67
 
72
68
  matches.forEach((match) => {
73
- const variables = match[2]
69
+ // Clean out formatting line-breaks, tabs, or rogue inner code comments
70
+ const cleanedVariablesBlock = match[2]
71
+ .replace(/\/\/.*$/gm, '') // strip inline comments
72
+ .replace(/\/\*[\s\S]*?\*\//g, '') // strip block comments
73
+ .replace(/[\r\n\t]/g, ' '); // normalize lines to spaces
74
+
75
+ const variables = cleanedVariablesBlock
74
76
  .split(',')
75
77
  .map(v => v.trim())
76
78
  .filter(Boolean);
@@ -78,32 +80,30 @@ export function endtesterExpress() {
78
80
  variables.forEach((field) => {
79
81
  let realField = field;
80
82
 
81
- // support aliases
82
- // name: username
83
+ // Support aliases (e.g., name: username)
83
84
  if (field.includes(':')) {
84
85
  realField = field.split(':')[0].trim();
85
86
  }
86
87
 
87
- // remove defaults
88
- // age = 0
88
+ // Remove defaults values (e.g., age = 0)
89
89
  if (realField.includes('=')) {
90
90
  realField = realField.split('=')[0].trim();
91
91
  }
92
92
 
93
- // avoid duplicates
93
+ // Clean any trailing whitespace variations
94
+ realField = realField.trim();
95
+
94
96
  const alreadyExists = fields.find(
95
97
  f => f.name === realField
96
98
  );
97
99
 
98
- if (!alreadyExists) {
100
+ if (!alreadyExists && realField) {
99
101
  fields.push({
100
102
  name: realField,
101
103
  label:
102
104
  realField.charAt(0).toUpperCase() +
103
105
  realField.slice(1),
104
-
105
106
  type: detectInputType(realField),
106
-
107
107
  placeholder: `Enter ${realField}`
108
108
  });
109
109
  }
@@ -182,7 +182,7 @@ export function endtesterExpress() {
182
182
  }
183
183
  });
184
184
 
185
- // remove duplicates
185
+ // Remove duplicates
186
186
  bodyFields = bodyFields.filter(
187
187
  (field, index, self) =>
188
188
  index ===
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aimeloic/monkey-tester",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Auto route scanning visual runner dashboard.",
5
5
  "main": "index.js",
6
6
  "type": "module",