Browse Source

Minor cleanups

Jordi Boggiano 13 years ago
parent
commit
837ef2956e
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/Packagist/WebBundle/Controller/ApiController.php

+ 3 - 4
src/Packagist/WebBundle/Controller/ApiController.php

@@ -68,20 +68,19 @@ class ApiController extends Controller
             return new Response(json_encode(array('status' => 'error', 'message' => 'Invalid credentials',)), 403);
         }
 
-        if (! preg_match('~(github.com/[\w_\-\.]+/[\w_\-\.]+)$~', $payload['repository']['url'], $matches)) {
+        if (!preg_match('{github.com/[\w.-]+/[\w.-]+$}', $payload['repository']['url'], $match)) {
             return new Response(json_encode(array('status' => 'error', 'message' => 'Could not parse payload repository URL',)), 406);
         }
 
-        $payloadRepositoryChunk = $matches[1];
+        $payloadRepositoryChunk = $match[0];
 
         foreach ($user->getPackages() as $package) {
             if (false !== strpos($package->getRepository(), $payloadRepositoryChunk)) {
                 // We found the package that was referenced.
-
                 $updater = new Updater($doctrine);
                 $updater->update($package);
 
-                return new Response('{ "status": "success" }', 202);
+                return new Response('{"status": "success"}', 202);
             }
         }