@pixelbyte-software/pixcode 1.31.6 → 1.31.7
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.
- package/dist/assets/{index-BpiNFjaI.js → index-DY32Zt8F.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/server/index.js +6 -2
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/routes/plugins.js +19 -8
- package/dist-server/server/routes/plugins.js.map +1 -1
- package/package.json +1 -1
- package/server/index.js +6 -2
- package/server/routes/plugins.js +19 -8
package/server/index.js
CHANGED
|
@@ -2444,8 +2444,12 @@ app.get('/api/projects/:projectName/sessions/:sessionId/token-usage', authentica
|
|
|
2444
2444
|
}
|
|
2445
2445
|
});
|
|
2446
2446
|
|
|
2447
|
-
// Serve React app for all other routes (excluding static files)
|
|
2448
|
-
|
|
2447
|
+
// Serve React app for all other routes (excluding static files).
|
|
2448
|
+
// Regex instead of the string '*' because path-to-regexp v8 rejects the
|
|
2449
|
+
// bare wildcard with "Missing parameter name at index 0". /.*/ works on
|
|
2450
|
+
// every version and does exactly what the old `'*'` used to do: match
|
|
2451
|
+
// everything that didn't hit a more specific route above.
|
|
2452
|
+
app.get(/.*/, (req, res) => {
|
|
2449
2453
|
// Skip requests for static assets (files with extensions)
|
|
2450
2454
|
if (path.extname(req.path)) {
|
|
2451
2455
|
return res.status(404).send('Not found');
|
package/server/routes/plugins.js
CHANGED
|
@@ -53,13 +53,21 @@ router.get('/:name/manifest', (req, res) => {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
// GET /:name/assets/* — Serve plugin static files
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
// GET /:name/assets/* — Serve plugin static files.
|
|
57
|
+
//
|
|
58
|
+
// The pattern is written as a literal RegExp rather than an Express route
|
|
59
|
+
// string because path-to-regexp v8 (pulled in as a transitive dep by any
|
|
60
|
+
// Express 5 beta / Router v2) rejects the `*` unnamed wildcard with
|
|
61
|
+
// "Missing parameter name at index 15" and the app refuses to boot. A
|
|
62
|
+
// regex sidesteps path-to-regexp entirely and works on every version of
|
|
63
|
+
// Express / path-to-regexp we've tested. Capture groups land in
|
|
64
|
+
// req.params[0] / [1] — same wire as the old `:name` + `*` would give us.
|
|
65
|
+
router.get(/^\/([a-zA-Z0-9_-]+)\/assets\/(.+)$/, (req, res) => {
|
|
66
|
+
const pluginName = req.params[0];
|
|
59
67
|
if (!/^[a-zA-Z0-9_-]+$/.test(pluginName)) {
|
|
60
68
|
return res.status(400).json({ error: 'Invalid plugin name' });
|
|
61
69
|
}
|
|
62
|
-
const assetPath = req.params[
|
|
70
|
+
const assetPath = req.params[1];
|
|
63
71
|
|
|
64
72
|
if (!assetPath) {
|
|
65
73
|
return res.status(400).json({ error: 'No asset path specified' });
|
|
@@ -203,10 +211,13 @@ router.post('/:name/update', async (req, res) => {
|
|
|
203
211
|
}
|
|
204
212
|
});
|
|
205
213
|
|
|
206
|
-
// ALL /:name/rpc/* — Proxy requests to plugin's server subprocess
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
214
|
+
// ALL /:name/rpc/* — Proxy requests to plugin's server subprocess.
|
|
215
|
+
// Same path-to-regexp v8 avoidance trick as /:name/assets/* above — we
|
|
216
|
+
// use a RegExp directly so the router can't invoke path-to-regexp on
|
|
217
|
+
// the unnamed wildcard.
|
|
218
|
+
router.all(/^\/([a-zA-Z0-9_-]+)\/rpc\/(.*)$/, async (req, res) => {
|
|
219
|
+
const pluginName = req.params[0];
|
|
220
|
+
const rpcPath = req.params[1] || '';
|
|
210
221
|
|
|
211
222
|
if (!/^[a-zA-Z0-9_-]+$/.test(pluginName)) {
|
|
212
223
|
return res.status(400).json({ error: 'Invalid plugin name' });
|