wiki-plugin-mech

This page is a Plugin and a Topicmap. dmx

Paul via matrix | The problem with the mech's server component is most likely due to changes in the Express api with the upgrade to v5.

a JSReturnStatementNode

The error probably occurs because Express 5 parses routing patterns more strictly. The issue with the regular expression pattern may be related to how the route parameters are defined. matrix , page

See code

return app.get('/plugin/mech/run/:slug([a-z-]+)/:itemId', cors, (req, res, next) => …

Error:

failed to start plugin wiki-plugin-mech TypeError: Unexpected ( at 22, expected END: https://git.new/pathToRegexpError –– Path-to-RegExp. page

> Regexp characters are not supported.

Here's one way to fix this:

// Change this: app.get('/plugin/mech/run/:slug([a-z-]+)/:itemId', cors, (req, res, next) => { // To this: app.get('/plugin/mech/run/:slug/:itemId', cors, (req, res, next) => {

Then add validation inside the handler:

// Inside the route handler: const slug = req.params.slug; if (!slug.match(/^[a-z-]+$/)) { return res.status(400).json({ error: 'Invalid slug format' }); }

This change:

Removes the problematic regex from the route path

Adds manual validation of the slug format

Maintains the same security checks

Works with Express 5's stricter router

pages/wiki-plugin-mech