Skip to content

Commit b6a5ca7

Browse files
authored
Merge pull request #28 from madewithlove/new-payload-for-share-call
New payload for share call
2 parents bccffd3 + d28498b commit b6a5ca7

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ HTTP_REFERER
5959
SERVER_NAME
6060
```
6161

62-
Server variables can be passed to the `test()` method.
62+
Server variables can be passed to the `test()` and `share()` methods.
6363
```php
6464
$serverVariables = ServerVariables::default()->with(
6565
ServerVariable::SERVER_NAME,
@@ -72,4 +72,11 @@ $response = $client->test(
7272
RewriteRule .* /foo [R]',
7373
$serverVariables
7474
);
75+
76+
$response = $client->share(
77+
'http://localhost',
78+
'RewriteCond %{SERVER_NAME} example.com
79+
RewriteRule .* /foo [R]',
80+
$serverVariables
81+
);
7582
```

src/HtaccessClient.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ function (array $line) {
5757
public function share(
5858
string $url,
5959
string $htaccess,
60-
?string $referrer = '',
61-
?string $serverName = ''
60+
?ServerVariables $serverVariables = null
6261
): ShareResult {
62+
$serverVariables = $serverVariables ?? ServerVariables::default();
6363
$responseData = $this->request(
6464
'POST',
6565
'/share',
6666
[
6767
'url' => $url,
6868
'htaccess' => $htaccess,
69-
'referrer' => $referrer ?? '',
70-
'server_name' => $serverName ?? '',
69+
'serverVariables' => $serverVariables->toArray()
7170
]
7271
);
7372

tests/HtaccessClientTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function it can share a test run with a referer(): void
189189
'http://localhost',
190190
'RewriteCond %{HTTP_REFERER} http://example.com
191191
RewriteRule .* /example-page [L]',
192-
'http://example.com'
192+
ServerVariables::default()->with(ServerVariable::HTTP_REFERER, 'http://example.com')
193193
);
194194

195195
$this->assertStringStartsWith(
@@ -222,8 +222,7 @@ public function it can share a test run with a server name(): void
222222
'http://localhost',
223223
'RewriteCond %{SERVER_NAME} example.com
224224
RewriteRule .* /example-page [L]',
225-
null,
226-
'example.com'
225+
ServerVariables::default()->with(ServerVariable::SERVER_NAME, 'example.com')
227226
);
228227

229228
$this->assertStringStartsWith(

0 commit comments

Comments
 (0)