node-wpapi icon indicating copy to clipboard operation
node-wpapi copied to clipboard

Another broken Regular Expression route

Open devinellis opened this issue 4 years ago • 2 comments

I think this is related to https://github.com/WP-API/node-wpapi/issues/476

SyntaxError: Invalid regular expression: /stk_design_library(?:/: Unterminated group
    at new RegExp (<anonymous>)
    at reduceRouteComponents (/var/www/node_modules/wpapi/lib/route-tree.js:83:3)
    at Array.reduce (<anonymous>)
    at reduceRouteTree (/var/www/node_modules/wpapi/lib/route-tree.js:182:18)
    at /var/www/node_modules/wpapi/lib/util/object-reduce.js:25:20
    at Array.reduce (<anonymous>)
    at module.exports (/var/www/node_modules/wpapi/lib/util/object-reduce.js:24:3)
    at buildRouteTree (/var/www/node_modules/wpapi/lib/route-tree.js:200:9)
    at WPAPI.bootstrap (/var/www/node_modules/wpapi/wpapi.js:349:23)
    at new WPAPI (/var/www/node_modules/wpapi/wpapi.js:88:4)
Endpoint detected, proceeding despite error...
Binding to https://<redacted>/wp-json/ and assuming default routes

The route key in the JSON body is /wp/v2/stk_design_library(?:/(?P<reset>reset))?

What I am trying to achieve is to get the /plugins routes to mount, and they don't seem to be included in the "default routes" mentioned in the error log. This makes me wonder, why not test each key and skip it instead of throwing out the whole thing? (I am making assumptions here)

Thanks in advance for the help!

devinellis avatar Sep 22 '21 04:09 devinellis

Since I didn't hear back I ended up removing WPAPI as a dependency, and instead make node-fetch calls directly for the endpoints I need.

devinellis avatar Sep 28 '21 19:09 devinellis

This looks like the same issue as https://github.com/WP-API/node-wpapi/issues/503?

samfreedman avatar Apr 03 '22 11:04 samfreedman