From fd4ce8695efac40d7bb6d3e4166df006c5741726 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 2 May 2011 11:46:06 +0000 Subject: [PATCH] getBaseURL(): Handle empty baseurlpath. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2824 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Configuration.php | 3 +++ lib/SimpleSAML/Utilities.php | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index ac86d2d3f..0da51db37 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -358,6 +358,9 @@ class SimpleSAML_Configuration { if (preg_match('#^https?://[^/]*/(.*)$#', $baseURL, $matches)) { /* we have a full url, we need to strip the path */ return $matches[1]; + } elseif ($baseURL === '' || $baseURL === '/') { + /* Root directory of site. */ + return ''; } elseif (preg_match('#^/?([^/]?.*/)#D', $baseURL, $matches)) { /* local path only */ return $matches[1]; diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 7172b8364..d3c3909fb 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -217,7 +217,8 @@ class SimpleSAML_Utilities { return $baseURL; } elseif ( (preg_match('#^/?([^/]?.*/)$#D', $baseURL, $matches)) || - (preg_match('#^\*(.*)/$#D', $baseURL, $matches))) { + (preg_match('#^\*(.*)/$#D', $baseURL, $matches)) || + ($baseURL === '')) { /* get server values */ if (self::getServerHTTPS()) { @@ -228,8 +229,7 @@ class SimpleSAML_Utilities { $hostname = self::getServerHost(); $port = self::getServerPort(); - $path = $globalConfig->getBaseURL(); - if ($path[0] != '/') $path = '/' . $path; + $path = '/' . $globalConfig->getBaseURL(); return $protocol.$hostname.$port.$path; } else { -- GitLab