|
35 | 35 | use function rawurldecode; |
36 | 36 | use function rtrim; |
37 | 37 | use function str_replace; |
| 38 | +use function str_starts_with; |
38 | 39 | use function stripos; |
39 | 40 | use function strlen; |
40 | 41 | use function strpos; |
@@ -188,8 +189,12 @@ class Request |
188 | 189 | /** |
189 | 190 | * Constructor. |
190 | 191 | */ |
191 | | - public function __construct(array $request = [], ?Signer $signer = null, ?string $scriptName = null) |
192 | | - { |
| 192 | + public function __construct( |
| 193 | + array $request = [], |
| 194 | + ?Signer $signer = null, |
| 195 | + ?string $scriptName = null, |
| 196 | + protected ?string $ingressPrefix = null |
| 197 | + ) { |
193 | 198 | // Collect request data |
194 | 199 |
|
195 | 200 | $this->query = new Parameters($request['get'] ?? $_GET); |
@@ -217,6 +222,20 @@ public function __construct(array $request = [], ?Signer $signer = null, ?string |
217 | 222 | $this->method = $request['method'] ?? $this->determineMethod(); |
218 | 223 | } |
219 | 224 |
|
| 225 | + /** |
| 226 | + * Strips the ingress prefix from the path. |
| 227 | + */ |
| 228 | + protected function stripIngressPrefix(string $path): string |
| 229 | + { |
| 230 | + if ($this->ingressPrefix) { |
| 231 | + if (str_starts_with($path, $this->ingressPrefix)) { |
| 232 | + return mb_substr($path, mb_strlen($this->ingressPrefix)); |
| 233 | + } |
| 234 | + } |
| 235 | + |
| 236 | + return $path; |
| 237 | + } |
| 238 | + |
220 | 239 | /** |
221 | 240 | * Strips the locale segment from the path. |
222 | 241 | */ |
@@ -271,7 +290,7 @@ protected function determinePath(array $languages): string |
271 | 290 | } |
272 | 291 | } |
273 | 292 |
|
274 | | - return $this->stripLocaleSegment($languages, $path); |
| 293 | + return $this->stripLocaleSegment($languages, $this->stripIngressPrefix($path)); |
275 | 294 | } |
276 | 295 |
|
277 | 296 | /** |
|
0 commit comments