Fix path handling on Windows
Fixes #307; thank you @bpgs for reporting!
This commit is contained in:
parent
14e5f3236c
commit
5be2f8e597
3 changed files with 13 additions and 6 deletions
|
@ -15,6 +15,7 @@ Released: -
|
|||
with a title in the navigation
|
||||
* [Changed] #292: Ignore YAML parse errors (meta data) in `Pico::readPages()`
|
||||
* [Fixed] Support empty meta header
|
||||
* [Fixed] #307: Fix path handling on Windows
|
||||
```
|
||||
|
||||
### Version 1.0.0-beta.2
|
||||
|
|
16
lib/Pico.php
16
lib/Pico.php
|
@ -213,7 +213,7 @@ class Pico
|
|||
*/
|
||||
public function __construct($rootDir, $configDir, $pluginsDir, $themesDir)
|
||||
{
|
||||
$this->rootDir = rtrim($rootDir, '/') . '/';
|
||||
$this->rootDir = rtrim($rootDir, '/\\') . '/';
|
||||
$this->configDir = $this->getAbsolutePath($configDir);
|
||||
$this->pluginsDir = $this->getAbsolutePath($pluginsDir);
|
||||
$this->themesDir = $this->getAbsolutePath($themesDir);
|
||||
|
@ -1219,7 +1219,7 @@ class Pico
|
|||
|
||||
$this->config['base_url'] =
|
||||
$protocol . "://" . $_SERVER['HTTP_HOST']
|
||||
. rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/';
|
||||
. rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\') . '/';
|
||||
|
||||
return $this->getConfig('base_url');
|
||||
}
|
||||
|
@ -1323,10 +1323,16 @@ class Pico
|
|||
*/
|
||||
public function getAbsolutePath($path)
|
||||
{
|
||||
if (substr($path, 0, 1) !== '/') {
|
||||
$path = $this->getRootDir() . $path;
|
||||
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
|
||||
if (preg_match('/^([a-zA-Z]:\\\\|\\\\\\\\)/', $path) !== 1) {
|
||||
$path = $this->getRootDir() . $path;
|
||||
}
|
||||
} else {
|
||||
if (substr($path, 0, 1) !== '/') {
|
||||
$path = $this->getRootDir() . $path;
|
||||
}
|
||||
}
|
||||
return rtrim($path, '/') . '/';
|
||||
return rtrim($path, '/\\') . '/';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -175,7 +175,7 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||
$config['base_url'] = rtrim($config['base_url'], '/') . '/';
|
||||
}
|
||||
if (isset($config['content_dir'])) {
|
||||
$config['content_dir'] = rtrim($config['content_dir'], '/') . '/';
|
||||
$config['content_dir'] = rtrim($config['content_dir'], '/\\') . '/';
|
||||
}
|
||||
|
||||
$realConfig = $config + $realConfig;
|
||||
|
|
Loading…
Add table
Reference in a new issue