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

View File

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

View File

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

View File

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