Skip to content

Commit

Permalink
Merge pull request #28 from madewithlove/new-payload-for-share-call
Browse files Browse the repository at this point in the history
New payload for share call
  • Loading branch information
jdrieghe authored Oct 8, 2021
2 parents bccffd3 + d28498b commit b6a5ca7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
);
```
7 changes: 3 additions & 4 deletions src/HtaccessClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]
);

Expand Down
5 changes: 2 additions & 3 deletions tests/HtaccessClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b6a5ca7

Please sign in to comment.