Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / controller / DiffusionRepositoryDefaultController.php
bloba83829ccc4a7c4f5c354e9721108c75f1377c529
1 <?php
3 final class DiffusionRepositoryDefaultController extends DiffusionController {
5 public function shouldAllowPublic() {
6 // NOTE: We allow public access to this controller because it handles
7 // redirecting paths that are missing a trailing "/". We need to manually
8 // redirect these instead of relying on the automatic redirect because
9 // some VCS requests may omit the slashes. See T12035, and below, for some
10 // discussion.
11 return true;
14 public function handleRequest(AphrontRequest $request) {
15 $response = $this->loadDiffusionContext();
16 if ($response) {
17 return $response;
20 // NOTE: This controller is just here to make sure we call
21 // willBeginExecution() on any /diffusion/X/ URI, so we can intercept
22 // `git`, `hg` and `svn` HTTP protocol requests.
24 // If we made it here, it's probably because the user copy-pasted a
25 // clone URI with "/anything.git" at the end into their web browser.
26 // Send them to the canonical repository URI.
28 $drequest = $this->getDiffusionRequest();
29 $repository = $drequest->getRepository();
31 return id(new AphrontRedirectResponse())
32 ->setURI($repository->getURI());