소스 검색

Handle github URLs with a trailing slash

Jordi Boggiano 9 년 전
부모
커밋
6200a24b6a
2개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/Packagist/WebBundle/Controller/ApiController.php
  2. 1 0
      src/Packagist/WebBundle/Tests/Controller/ApiControllerTest.php

+ 1 - 1
src/Packagist/WebBundle/Controller/ApiController.php

@@ -111,7 +111,7 @@ class ApiController extends Controller
         }
 
         if (isset($payload['repository']['url'])) { // github/gitlab/anything hook
-            $urlRegex = '{^(?:ssh://git@|https?://|git://|git@)?(?P<host>[a-z0-9.-]+)(?::[0-9]+/|[:/])(?P<path>[\w.-]+/[\w.-]+?)(?:\.git)?$}i';
+            $urlRegex = '{^(?:ssh://git@|https?://|git://|git@)?(?P<host>[a-z0-9.-]+)(?::[0-9]+/|[:/])(?P<path>[\w.-]+/[\w.-]+?)(?:\.git|/)?$}i';
             $url = $payload['repository']['url'];
         } elseif (isset($payload['repository']['links']['html']['href'])) { // bitbucket push event payload
             $urlRegex = '{^(?:https?://|git://|git@)?(?:api\.)?(?P<host>bitbucket\.org)[/:](?P<path>[\w.-]+/[\w.-]+?)(\.git)?/?$}i';

+ 1 - 0
src/Packagist/WebBundle/Tests/Controller/ApiControllerTest.php

@@ -100,6 +100,7 @@ class ApiControllerTest extends WebTestCase
             array('github', 'git://github.com/user/repo', true),
             array('github', 'git@github.com:user/repo.git', true),
             array('github', 'git@github.com:user/repo', true),
+            array('github', 'https://github.com/user/repo/', true),
 
             // valid bitbucket URLs
             array('bitbucket', 'bitbucket.org/user/repo', true),