diff --git a/README.md b/README.md index 7c9fcda..7feefbd 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ HTTP_REFERER SERVER_NAME ``` -Server variables can be passed to the `test()` method. +Server variables can be passed to the `test()` and `share()` methods. ```php $serverVariables = ServerVariables::default()->with( ServerVariable::SERVER_NAME, @@ -72,4 +72,11 @@ $response = $client->test( RewriteRule .* /foo [R]', $serverVariables ); + +$response = $client->share( + 'http://localhost', + 'RewriteCond %{SERVER_NAME} example.com + RewriteRule .* /foo [R]', + $serverVariables +); ``` diff --git a/src/HtaccessClient.php b/src/HtaccessClient.php index a3b591a..beb419c 100644 --- a/src/HtaccessClient.php +++ b/src/HtaccessClient.php @@ -57,17 +57,16 @@ function (array $line) { public function share( string $url, string $htaccess, - ?string $referrer = '', - ?string $serverName = '' + ?ServerVariables $serverVariables = null ): ShareResult { + $serverVariables = $serverVariables ?? ServerVariables::default(); $responseData = $this->request( 'POST', '/share', [ 'url' => $url, 'htaccess' => $htaccess, - 'referrer' => $referrer ?? '', - 'server_name' => $serverName ?? '', + 'serverVariables' => $serverVariables->toArray() ] ); diff --git a/tests/HtaccessClientTest.php b/tests/HtaccessClientTest.php index 5ae9c5b..b048241 100644 --- a/tests/HtaccessClientTest.php +++ b/tests/HtaccessClientTest.php @@ -189,7 +189,7 @@ public function it can share a test run with a referer(): void 'http://localhost', 'RewriteCond %{HTTP_REFERER} http://example.com RewriteRule .* /example-page [L]', - 'http://example.com' + ServerVariables::default()->with(ServerVariable::HTTP_REFERER, 'http://example.com') ); $this->assertStringStartsWith( @@ -222,8 +222,7 @@ public function it can share a test run with a server name(): void 'http://localhost', 'RewriteCond %{SERVER_NAME} example.com RewriteRule .* /example-page [L]', - null, - 'example.com' + ServerVariables::default()->with(ServerVariable::SERVER_NAME, 'example.com') ); $this->assertStringStartsWith(