Skip to content
Snippets Groups Projects
Commit 337bd08f authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utilities::getFirstPathElement() to...

Move SimpleSAML_Utilities::getFirstPathElement() to SimpleSAML\Utils\HTTP::getFirstPathElement() and deprecate the former.
parent e911e267
Branches
Tags
No related merge requests found
......@@ -346,7 +346,7 @@ class SimpleSAML_Configuration {
if (preg_match('/^\*(.*)$/D', $baseURL, $matches)) {
/* deprecated behaviour, will be removed in the future */
return SimpleSAML_Utilities::getFirstPathElement(false) . $matches[1];
return \SimpleSAML\Utils\HTTP::getFirstPathElement(false) . $matches[1];
}
if (preg_match('#^https?://[^/]*/(.*)$#', $baseURL, $matches)) {
......
......@@ -92,18 +92,15 @@ class SimpleSAML_Utilities {
public static function getSelfHostWithPath() {
return \SimpleSAML\Utils\HTTP::getSelfHostWithPath();
}
/**
* Will return foo
* @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getFirstPathElement() instead.
*/
public static function getFirstPathElement($trailingslash = true) {
if (preg_match('|^/(.*?)/|', $_SERVER['SCRIPT_NAME'], $matches)) {
return ($trailingslash ? '/' : '') . $matches[1];
}
return '';
return \SimpleSAML\Utils\HTTP::getFirstPathElement($trailingslash);
}
public static function selfURL() {
......
......@@ -316,6 +316,24 @@ class HTTP
}
/**
* Retrieve the first element of the URL path.
*
* @param boolean $trailingslash Whether to add a trailing slash to the element or not. Defaults to true.
*
* @return string The first element of the URL path, with an optional, trailing slash.
*
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
*/
public static function getFirstPathElement($trailingslash = true)
{
if (preg_match('|^/(.*?)/|', $_SERVER['SCRIPT_NAME'], $matches)) {
return ($trailingslash ? '/' : '').$matches[1];
}
return '';
}
/**
* Retrieve our own host.
*
......
......@@ -21,7 +21,7 @@ $attributes['Utilities_getSelfHost()'] = array(\SimpleSAML\Utils\HTTP::getSelfHo
$attributes['Utilities_selfURLhost()'] = array(SimpleSAML_Utilities::selfURLhost());
$attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery());
$attributes['Utilities_getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithPath());
$attributes['Utilities_getFirstPathElement()'] = array(SimpleSAML_Utilities::getFirstPathElement());
$attributes['Utilities_getFirstPathElement()'] = array(\SimpleSAML\Utils\HTTP::getFirstPathElement());
$attributes['Utilities_selfURL()'] = array(SimpleSAML_Utilities::selfURL());
$et = new SimpleSAML_XHTML_Template($config, 'hostnames.php');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment