Closed cedx closed 5 years ago
@cedx the behaviour you are experiencing is expected. What you are looking for is URL resolution which is not define in PSR-7 but in RFC3986 instead for instance you can accompish this using the Resolve modifier as explain in the documentation website see https://uri.thephpleague.com/manipulations/1.0/middlewares/#middlewares-which-manipulate-several-uri-components.
<?php
use League\Uri\Schemes\Http;
use League\Uri\Modifiers\Resolve;
$baseUri = Http::createFromString('https://belin.io/api/')
$relativeUri = Http::createFromString("v1");
$modifier = new Resolve($baseUri);
$newUri = $modifier->process($relativeUri);
echo $newUri; //displays "https://belin.io/api/v1"
Thanks for the clarification and the solution to my problem 😃
The documentation of the withPath
method should probably be modified: the observed behavior is different from the description (i.e. we can't use "rootless" paths).
Issue summary
PSR-7 and the documentation of the
AbstractUri
class say about the$path
parameter provided to thewithPath()
method:But that's not the case currently: using a relative path triggers an exception.
System informations
Standalone code, or other way to reproduce the problem
Expected result
No exception, just a valid URI:
https://belin.io/api/v1
Actual result