diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index 8cd69abe48488535d37e47c79b6c202688926e01..83f66a810e1696f59621c4352da30c4a0e3e4a20 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -110,10 +110,10 @@ class UrlHelper {
 			$rel_parts['host'] = $base_parts['host'] ?? "";
 			$rel_parts['scheme'] = $base_parts['scheme'] ?? "";
 
-			if (isset($rel_parts['path'])) {
+			if ($rel_parts['path'] ?? "") {
 
 				// we append dirname() of base path to relative URL path as per RFC 3986 section 5.2.2
-				$base_path = with_trailing_slash(dirname($base_parts['path']));
+				$base_path = with_trailing_slash(dirname($base_parts['path'] ?? ""));
 
 				// 1. absolute relative path (/test.html) = no-op, proceed as is