mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-04-11 06:57:56 +02:00
Changes to Route to work with Windows
Addition of function to test which OS and replace \ with \\ on windows.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user