public function getBasePath()
{
$baseURL = $this->getString('baseurlpath', 'simplesaml/');
if (preg_match('#^https?://[^/]*(?:/(.+/?)?)?$#', $baseURL, $matches)) {
// we have a full url, we need to strip the path
if (!array_key_exists(1, $matches)) {
// absolute URL without path
return '/';
}
return '/' . rtrim($matches[1], '/') . "/";
} elseif ($baseURL === '' || $baseURL === '/') {
// root directory of site
return '/';
} elseif (preg_match('#^/?((?:[^/\\s]+/?)+)#', $baseURL, $matches)) {
// local path only
return '/' . rtrim($matches[1], '/') . '/';
} else {
/*
* Invalid 'baseurlpath'. We cannot recover from this, so throw a critical exception and try to be graceful
* with the configuration. Use a guessed base path instead of the one provided.
*/
$c = $this->toArray();
$c['baseurlpath'] = SimpleSAML\Utils\HTTP::guessBasePath();
throw new SimpleSAML\Error\CriticalConfigurationError('Incorrect format for option \'baseurlpath\'. Value is: "' . $this->getString('baseurlpath', 'simplesaml/') . '". Valid format is in the form' . ' [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/].', $this->filename, $c);
}
}