@aimeloic/monkey-tester 3.0.2 → 3.0.3

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 (2) hide show
  1. package/monkey.js +9 -1
  2. package/package.json +1 -1
package/monkey.js CHANGED
@@ -173,13 +173,19 @@ function parseStack(stack, detectedEndpoints, prefix = '') {
173
173
  }
174
174
 
175
175
  // ─── Middleware ───────────────────────────────────────────────────────────────
176
+ // ─── Middleware in monkey.js ──────────────────────────────────────────────────
176
177
  function endtesterExpress() {
177
178
  return function monkeyTesterMiddleware(req, res, next) {
178
- if (req.path !== '/api/tester' && req.path !== '/api/tester/') {
179
+ // Standard structural path cleaning
180
+ const normalPath = req.path.replace(/\/$/, ''); // removes trailing slash
181
+
182
+ if (normalPath !== '/api/tester') {
179
183
  return next();
180
184
  }
181
185
 
182
186
  const app = req.app;
187
+
188
+ // CRITICAL FIX: Reset the detected endpoints on each call to prevent stale empty states
183
189
  const detectedEndpoints = {};
184
190
 
185
191
  const rootStack =
@@ -187,8 +193,10 @@ function endtesterExpress() {
187
193
  (app.router && app.router.stack) || // Express 5
188
194
  [];
189
195
 
196
+ // Scan the live compiled routing stack
190
197
  parseStack(rootStack, detectedEndpoints);
191
198
 
199
+ // Render page template
192
200
  const html = getHtmlTemplate(detectedEndpoints);
193
201
  res.setHeader('Content-Type', 'text/html');
194
202
  return res.send(html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aimeloic/monkey-tester",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Auto route scanning visual runner dashboard.",
5
5
  "main": "index.js",
6
6
  "type": "module",