File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ final class AddPathPlugin implements Plugin
1818 */
1919 private $ uri ;
2020
21+ /**
22+ * Stores identifiers of the already altered requests.
23+ *
24+ * @var array
25+ */
26+ private $ alteredRequests = [];
27+
2128 /**
2229 * @param UriInterface $uri
2330 */
@@ -39,10 +46,13 @@ public function __construct(UriInterface $uri)
3946 */
4047 public function handleRequest (RequestInterface $ request , callable $ next , callable $ first )
4148 {
42- if (0 !== strpos ($ request ->getUri ()->getPath (), $ this ->uri ->getPath ())) {
49+ $ identifier = spl_object_hash ((object ) $ first );
50+
51+ if (!in_array ($ identifier , $ this ->alteredRequests )) {
4352 $ request = $ request ->withUri ($ request ->getUri ()
4453 ->withPath ($ this ->uri ->getPath ().$ request ->getUri ()->getPath ())
4554 );
55+ $ this ->alteredRequests [] = $ identifier ;
4656 }
4757
4858 return $ next ($ request );
You can’t perform that action at this time.
0 commit comments