From 4c572a7fee5cb45fd6f328933eee7c95e7de51cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?= Date: Wed, 2 Sep 2020 18:42:52 +0200 Subject: [PATCH] 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 (cherry picked from commit df6858df2ed3fc5c424591a5e09b900eb4ce0417) --- test/middleware-mockserver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/middleware-mockserver.js b/test/middleware-mockserver.js index 06bf3b9c6..bb31eabfa 100644 --- a/test/middleware-mockserver.js +++ b/test/middleware-mockserver.js @@ -98,7 +98,7 @@ var mocks = { } else if ( req.query.callback ) { callback = Promise.resolve( req.query.callback ); } else if ( req.method === "GET" ) { - callback = Promise.resolve( req.url.match( /^.+\/([^\/?.]+)\?.+$/ )[ 1 ] ); + callback = Promise.resolve( req.url.match( /^.+\/([^\/?]+)\?.+$/ )[ 1 ] ); } else { callback = getBody( req ).then( function( body ) { return body.trim().replace( "callback=", "" );