From fc30338c07a8d1836a8693b4e09fe7f800ecb6d7 Mon Sep 17 00:00:00 2001 From: Erik Anders <5753604+Naugrimm@users.noreply.github.com> Date: Tue, 16 May 2023 10:34:43 +0200 Subject: [PATCH] fix: order of routes, strip ~dev suffix refs #649 --- src/Controller/RepoController.php | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Controller/RepoController.php b/src/Controller/RepoController.php index 83a7d435..1eee1319 100644 --- a/src/Controller/RepoController.php +++ b/src/Controller/RepoController.php @@ -140,6 +140,24 @@ public function downloads(Request $request, Organization $organization): JsonRes return new JsonResponse(['status' => 'success'], JsonResponse::HTTP_CREATED); } + /** + * @Route("/p2/{package}~dev.json", + * host="{organization}{sep1}repo{sep2}{domain}", + * name="repo_package_provider_v2_dev", + * methods={"GET"}, + * defaults={"domain":"%domain%","sep1"="%organization_separator%","sep2"="%domain_separator%"}, + * requirements={"domain"="%domain%","package"="%package_name_pattern%","sep1"="%organization_separator%","sep2"="%domain_separator%"}) + * @Cache(public=false) + */ + public function providerV2Dev(Request $request, Organization $organization, string $package): JsonResponse + { + if (($package = preg_replace('/~dev$/', '', $package)) === null) { + throw new NotFoundHttpException(); + } + + return $this->providerV2($request, $organization, $package); + } + /** * @Route("/p2/{package}.json", * host="{organization}{sep1}repo{sep2}{domain}", @@ -169,20 +187,6 @@ public function providerV2(Request $request, Organization $organization, string return $response; } - /** - * @Route("/p2/{package}~dev.json", - * host="{organization}{sep1}repo{sep2}{domain}", - * name="repo_package_provider_v2_dev", - * methods={"GET"}, - * defaults={"domain":"%domain%","sep1"="%organization_separator%","sep2"="%domain_separator%"}, - * requirements={"domain"="%domain%","package"="%package_name_pattern%","sep1"="%organization_separator%","sep2"="%domain_separator%"}) - * @Cache(public=false) - */ - public function providerV2Dev(Request $request, Organization $organization, string $package): JsonResponse - { - return $this->providerV2($request, $organization, $package); - } - /** * @return array */