Tests: Recognize callbacks with dots in the Node.js mock server

This aligns the Node.js server with the previous PHP one in sending `mock.php`
as a callback if there's no `callback` parameter in the query string which is
triggered by a recently added test. This prevents the request crashing on that
Node.js server and printing a JS error:
```
TypeError: Cannot read property '1' of null
```

Closes gh-4764
Ref gh-4754
This commit is contained in:
Michał Gołębiowski-Owczarek 2020-09-02 18:42:52 +02:00 committed by GitHub
parent c18dc49699
commit df6858df2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,7 +101,7 @@ var mocks = {
} else if ( req.query.callback ) { } else if ( req.query.callback ) {
callback = Promise.resolve( req.query.callback ); callback = Promise.resolve( req.query.callback );
} else if ( req.method === "GET" ) { } else if ( req.method === "GET" ) {
callback = Promise.resolve( req.url.match( /^.+\/([^\/?.]+)\?.+$/ )[ 1 ] ); callback = Promise.resolve( req.url.match( /^.+\/([^\/?]+)\?.+$/ )[ 1 ] );
} else { } else {
callback = getBody( req ).then( function( body ) { callback = getBody( req ).then( function( body ) {
return body.trim().replace( "callback=", "" ); return body.trim().replace( "callback=", "" );