Skip to content

Commit 8e1d4ed

Browse files
authored
If a prefix is being used, add a leading slash.
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.
1 parent 7fa691d commit 8e1d4ed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/JsonApiClient.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,12 @@ protected function createRequest(
180180
$prefix = null;
181181
if (array_key_exists('path', $url)) {
182182
$prefix = trim($url['path'], '/');
183+
if (!empty($prefix)) {
184+
$prefix .= '/';
185+
}
183186
}
184187

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

187190
return new Request($method, $requestUri, $body, $prefix);
188191
}

0 commit comments

Comments
 (0)