Minor fixes to ParsoidVirtualRESTService
authorGergő Tisza <gtisza@wikimedia.org>
Thu, 7 Sep 2017 03:13:17 +0000 (03:13 +0000)
committerGergő Tisza <gtisza@wikimedia.org>
Thu, 7 Sep 2017 03:13:17 +0000 (03:13 +0000)
* fix URL standardization (follow-up to I675f8252a2)
* avoid warning when timeout is not provided

Change-Id: I2a6c099f52f78017f92de4c078e79de04f230dda

includes/libs/virtualrest/ParsoidVirtualRESTService.php

index a148a39..b03a647 100644 (file)
@@ -58,15 +58,14 @@ class ParsoidVirtualRESTService extends VirtualRESTService {
                        'url' => 'http://localhost:8000/',
                        'prefix' => 'localhost',
                        'domain' => 'localhost',
+                       'timeout' => null,
                        'forwardCookies' => false,
                        'HTTPProxy' => null,
                ], $params );
                // Ensure that the url parameter has a trailing slash.
-               $mparams['url'] = preg_replace(
-                       '#/?$#',
-                       '/',
-                       $mparams['url']
-               );
+               if ( substr( $mparams['url'], -1 ) !== '/' ) {
+                       $mparams['url'] .= '/';
+               }
                // Ensure the correct domain format: strip protocol, port,
                // and trailing slash if present.  This lets us use
                // $wgCanonicalServer as a default value, which is very convenient.