File tree 1 file changed +11
-1
lines changed
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
18
18
*/
19
19
private $ uri ;
20
20
21
+ /**
22
+ * Stores identifiers of the already altered requests.
23
+ *
24
+ * @var array
25
+ */
26
+ private $ alteredRequests = [];
27
+
21
28
/**
22
29
* @param UriInterface $uri
23
30
*/
@@ -39,10 +46,13 @@ public function __construct(UriInterface $uri)
39
46
*/
40
47
public function handleRequest (RequestInterface $ request , callable $ next , callable $ first )
41
48
{
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 )) {
43
52
$ request = $ request ->withUri ($ request ->getUri ()
44
53
->withPath ($ this ->uri ->getPath ().$ request ->getUri ()->getPath ())
45
54
);
55
+ $ this ->alteredRequests [] = $ identifier ;
46
56
}
47
57
48
58
return $ next ($ request );
You can’t perform that action at this time.
0 commit comments