Skip to content

Commit a9e2627

Browse files
committed
Added comment
1 parent d4241d7 commit a9e2627

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- RetryPlugin: Renamed the configuration options for the exception retry callback from `decider` to `exception_decider`
88
and `delay` to `exception_delay`. The old names still work but are deprecated.
9-
- AddPathPlugin does not add prefix if the prefix already is defined.
9+
- AddPathPlugin: Do not add the prefix if the URL already has the same prefix.
1010

1111

1212
## 1.8.2 - 2018-12-14

src/Plugin/AddPathPlugin.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ 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-
2821
/**
2922
* @param UriInterface $uri
3023
*/
@@ -42,6 +35,21 @@ public function __construct(UriInterface $uri)
4235
}
4336

4437
/**
38+
* Adds a prefix in the beginning of the URL's path. We will not add the prefix
39+
* if it already exists. This will of course not cover all the edge cases. For
40+
* example when you have a valid URL like `https://example.com/api/api/foo` and
41+
* you are using the prefix "/api".
42+
*
43+
* Some of the other edge cases are:
44+
* - request objects can be reused,
45+
* - plugin chains could be restarted
46+
* - multiple AddPathPlugins may exist in one chain.
47+
*
48+
* If one would like to cover all these scenarios one would have to add a custom
49+
* header to the request to indicate it has been rewritten by the plugin. This
50+
* implementation does not aim for pleasing all edge cases rather to be great
51+
* value for the 95% other use cases.
52+
*
4553
* {@inheritdoc}
4654
*/
4755
public function handleRequest(RequestInterface $request, callable $next, callable $first)

0 commit comments

Comments
 (0)