mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Fixed regression bug while processing versionning for rest paths
This commit is contained in:
parent
bf7c760ca9
commit
a15b17e08b
@ -37,6 +37,11 @@ class PathVersionMiddleware implements MiddlewareInterface
|
|||||||
$uri = $request->getUri();
|
$uri = $request->getUri();
|
||||||
$path = $uri->getPath();
|
$path = $uri->getPath();
|
||||||
|
|
||||||
|
// Exclude non-rest route
|
||||||
|
if (strpos($path, '/rest') !== 0) {
|
||||||
|
return $out($request, $response);
|
||||||
|
}
|
||||||
|
|
||||||
// If the path does not begin with the version number, prepend v1 by default for retrocompatibility purposes
|
// If the path does not begin with the version number, prepend v1 by default for retrocompatibility purposes
|
||||||
if (strpos($path, '/rest/v') !== 0) {
|
if (strpos($path, '/rest/v') !== 0) {
|
||||||
$parts = explode('/', $path);
|
$parts = explode('/', $path);
|
||||||
|
@ -44,4 +44,16 @@ class PathVersionMiddlewareTest extends TestCase
|
|||||||
$this->assertEquals('/rest/v1/bar/baz', $req->getUri()->getPath());
|
$this->assertEquals('/rest/v1/bar/baz', $req->getUri()->getPath());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function nonRestPathsAreNotProcessed()
|
||||||
|
{
|
||||||
|
$request = ServerRequestFactory::fromGlobals()->withUri(new Uri('/non-rest'));
|
||||||
|
$test = $this;
|
||||||
|
$this->middleware->__invoke($request, new Response(), function ($req) use ($request, $test) {
|
||||||
|
$test->assertSame($request, $req);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user