Use computed regex for repo

This commit is contained in:
Christian Schorn
2012-10-31 14:46:19 +01:00
parent 3c9205a079
commit 668cd97ebe
4 changed files with 13 additions and 13 deletions

View File

@@ -39,7 +39,7 @@ class BlobController implements ControllerProviderInterface
'tags' => $repository->getTags(),
));
})->assert('file', '.+')
->assert('repo', '[\w-._]+')
->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->bind('blob');
@@ -59,7 +59,7 @@ class BlobController implements ControllerProviderInterface
return new Response($blob, 200, $headers);
})->assert('file', '.+')
->assert('repo', '[\w-._]+')
->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->bind('blob_raw');

View File

@@ -38,7 +38,7 @@ class CommitController implements ControllerProviderInterface
'commits' => $categorized,
'file' => $file,
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->assert('file', '.+')
->value('branch', 'master')
@@ -63,7 +63,7 @@ class CommitController implements ControllerProviderInterface
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->bind('searchcommits');
$route->get('{repo}/commit/{commit}/', function($repo, $commit) use ($app) {
@@ -75,7 +75,7 @@ class CommitController implements ControllerProviderInterface
'repo' => $repo,
'commit' => $commit,
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('commit', '[a-f0-9^]+')
->bind('commit');
@@ -94,7 +94,7 @@ class CommitController implements ControllerProviderInterface
'tags' => $repository->getTags(),
'blames' => $blames,
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('file', '.+')
->assert('branch', '[\w-._\/]+')
->bind('blame');

View File

@@ -33,7 +33,7 @@ class MainController implements ControllerProviderInterface
'stats' => $stats,
'authors' => $authors,
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->value('branch', 'master')
->bind('stats');
@@ -49,7 +49,7 @@ class MainController implements ControllerProviderInterface
));
return new Response($html, 200, array('Content-Type' => 'application/rss+xml'));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->bind('rss');

View File

@@ -41,7 +41,7 @@ class TreeController implements ControllerProviderInterface
'tags' => $repository->getTags(),
'readme' => $app['util.repository']->getReadme($repo, $branch),
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->assert('tree', '.+')
->bind('tree');
@@ -65,19 +65,19 @@ class TreeController implements ControllerProviderInterface
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
));
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->bind('search');
$route->get('{repo}/{branch}/', function($repo, $branch) use ($app, $treeController) {
return $treeController($repo, $branch);
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->bind('branch');
$route->get('{repo}/', function($repo) use ($app, $treeController) {
return $treeController($repo);
})->assert('repo', '[\w-._]+')
})->assert('repo', $app['util.routing']->getRepositoryRegex())
->bind('repository');
$route->get('{repo}/{format}ball/{branch}', function($repo, $format, $branch) use ($app) {
@@ -108,7 +108,7 @@ class TreeController implements ControllerProviderInterface
'Content-Transfer-Encoding' => 'binary',
));
})->assert('format', '(zip|tar)')
->assert('repo', '[\w-._]+')
->assert('repo', $app['util.routing']->getRepositoryRegex())
->assert('branch', '[\w-._\/]+')
->bind('archive');