Changes to Route to work with Windows

Addition of function to test which OS and replace \ with \\ on windows.
This commit is contained in:
Toby Allen
2012-12-30 19:38:33 +00:00
parent 7e70ce5637
commit 6034d14346

View File

@@ -19,13 +19,20 @@ class Routing
if ($regex === null) {
$app = $this->app;
$self = $this;
$quotedPaths = array_map(
#function ($repo) use ($app) {
# return preg_quote($app['util.routing']->getRelativePath($repo['path']), '#');
#},
# TODO: return keys instead
function ($repo) use ($app) {
return $repo['name'];
function ($repo) use ($app, $self) {
$repoName = $repo['name'] ;
//Windows
if ($self->OSIsWindows()){
$repoName = str_replace('\\', '\\\\',$repoName);
}
return $repoName;
},
$this->app['git']->getRepositories($this->app['git.repos'])
);
@@ -35,6 +42,17 @@ class Routing
return $regex;
}
public function OSIsWindows()
{
switch(PHP_OS){
case 'WIN32':
case 'WINNT':
case 'Windows': return true;
default : return false;
}
}
/**
* Strips the base path from a full repository path