Skip to content

Commit

Permalink
If a prefix is being used, add a leading slash.
Browse files Browse the repository at this point in the history
The following error is thrown by Guzzle, when urls are being prefixed.

> User Deprecated: The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.
  • Loading branch information
richgerdes authored Jun 26, 2019
1 parent 7fa691d commit 8e1d4ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/JsonApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ protected function createRequest(
$prefix = null;
if (array_key_exists('path', $url)) {
$prefix = trim($url['path'], '/');
if (!empty($prefix)) {
$prefix .= '/';
}
}

$requestUri = $requestUri->withPath($prefix . '/' . trim($requestUri->getPath(), '/'));
$requestUri = $requestUri->withPath('/' . $prefix . trim($requestUri->getPath(), '/'));

return new Request($method, $requestUri, $body, $prefix);
}
Expand Down

0 comments on commit 8e1d4ed

Please sign in to comment.