Преглед на файлове

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),