diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index b5bdbb13b25a973b2940c2ae23448a9d7e0aedb7..a9c7bfc031a18570cd0f885a3a5b314f83a057df 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -67,14 +67,14 @@ class SimpleSAML_Utilities {
 
 
 	/**
-	 * Will return https://sp.example.org
+	 * Will return https://sp.example.org[:PORT]
 	 */
 	public static function selfURLhost() {
 
 		$url = self::getBaseURL();
 
 		$start = strpos($url,'://') + 3;
-		$length = strcspn($url,'/:',$start) + $start;
+		$length = strcspn($url,'/',$start) + $start;
 
 		return substr($url, 0, $length);
 	}