question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: namedGroup not determined correctly

See original GitHub issue

https://github.com/WP-API/node-wpapi/blob/7427d6fbee11cc0f20d5b977c75ff927a2c49dbf/lib/route-tree.js#L36

// component == (?P<post_ids>([a-zA-Z0-9_]\,?)+)
var namedGroup = component.match( namedGroupRE );
/*
 [ '(?P<post_ids>([a-zA-Z0-9_]\\,?)', 
  'post_ids',
  '([a-zA-Z0-9_]\\,?', <-- ERROR in RegExp: Unterminated group
  index: 0,
  input: '(?P<post_ids>([a-zA-Z0-9_]\\,?)+)' ]
*/

https://github.com/WP-API/node-wpapi/blob/7427d6fbee11cc0f20d5b977c75ff927a2c49dbf/lib/route-tree.js#L83

SyntaxError: Invalid regular expression: /^([a-zA-Z0-9_]\,?$/: Unterminated group
    at new RegExp (<anonymous>)
    at reduceRouteComponents (D:\Develop\parser\node_modules\wpapi\lib\route-tree.js:93:3)
    at Array.reduce (<anonymous>)
    at reduceRouteTree (D:\Develop\parser\node_modules\wpapi\lib\route-tree.js:193:18)
    at D:\Develop\parser\node_modules\wpapi\lib\util\object-reduce.js:24:10
    at Array.reduce (<anonymous>)
    at module.exports (D:\Develop\parser\node_modules\wpapi\lib\util\object-reduce.js:23:28)
    at buildRouteTree (D:\Develop\parser\node_modules\wpapi\lib\route-tree.js:208:9)
    at WPAPI.bootstrap (D:\Develop\parser\node_modules\wpapi\wpapi.js:348:23)
    at new WPAPI (D:\Develop\parser\node_modules\wpapi\wpapi.js:89:4)
    at D:\Develop\parser\node_modules\wpapi\wpapi.js:447:11
    at tryCatch (D:\Develop\parser\node_modules\es6-promise\dist\es6-promise.js:410:12)
    at invokeCallback (D:\Develop\parser\node_modules\es6-promise\dist\es6-promise.js:425:13)
    at publish (D:\Develop\parser\node_modules\es6-promise\dist\es6-promise.js:393:7)
    at flush (D:\Develop\parser\node_modules\es6-promise\dist\es6-promise.js:121:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
sebakerckhofcommented, Oct 16, 2020

Workaround in wordpress:

add_filter( 'rest_endpoints', 'remove_default_endpoints_smarter' );
  
function remove_default_endpoints_smarter( $endpoints ) {
	//  workaround for npm wpapi bug
  foreach ( $endpoints as $endpoint => $details ) {
		if (strpos($endpoint, 'plugins') !== false) {
			unset( $endpoints[$endpoint] );
		}
  }
 
  return $endpoints;
}
1reaction
Triloworldcommented, Dec 18, 2020

Pleas reopen - find that bug. Fix from @sebakerckhof help but that disable route and don’t fix new patterns like “(?:<pattern>)” as @SamiSousa mention

Read more comments on GitHub >

github_iconTop Results From Across the Web

`openssl dhparam` cannot validate named group DH ...
The validation works properly on Ubuntu 20.04 as well as Fedora with OpenSSL 1.1.1 and CentOS Stream 9 with OpenSSL 3.0. Oddly, it...
Read more >
Regex Named Groups in Java - Stack Overflow
only being able to have one named group per same name (which you don't always have control over!) and not being able to...
Read more >
Regex Tutorial - Named Capturing Groups - Backreference ...
Doing so will give a regex compilation error. XRegExp 2 allowed them, but did not handle them correctly. In Perl 5.10, PCRE 8.00,...
Read more >
searchmanager : Error extracting fields - Splunk Community
I decided to extract the field in props.conf, but I encountered an error anyway: No results found. search="index=jobevent NOT "Racu name" | stats...
Read more >
Troubleshooting Automated Configuration for Citrix Virtual ...
Ensure that the Automated Configuration tool is not installed and running from ... and correct on the command line or customerinfo.yml file: <error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found