summaryrefslogtreecommitdiff
path: root/classes/urlhelper.php
diff options
context:
space:
mode:
authorwn <[email protected]>2020-12-12 10:04:22 -0600
committerwn <[email protected]>2020-12-12 10:28:53 -0600
commit95d0cb4953b93ed7b40556ff5c79327b0cde5c32 (patch)
treeca1e3113764d112f1b12380be4096b67a485b56c /classes/urlhelper.php
parentc68f2aabc929221b6c5af5ff51d28b990f6cd0f1 (diff)
Handle potential absence of a URL path in UrlHelper.
Diffstat (limited to 'classes/urlhelper.php')
-rw-r--r--classes/urlhelper.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index cc1074c55..fec36de51 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -1,8 +1,9 @@
<?php
class UrlHelper {
static function build_url($parts) {
- $tmp = $parts['scheme'] . "://" . $parts['host'] . $parts['path'];
+ $tmp = $parts['scheme'] . "://" . $parts['host'];
+ if (isset($parts['path'])) $tmp .= $parts['path'];
if (isset($parts['query'])) $tmp .= '?' . $parts['query'];
if (isset($parts['fragment'])) $tmp .= '#' . $parts['fragment'];
@@ -35,11 +36,13 @@ class UrlHelper {
$rel_parts['host'] = $parts['host'];
$rel_parts['scheme'] = $parts['scheme'];
- if (strpos($rel_parts['path'], '/') !== 0)
- $rel_parts['path'] = '/' . $rel_parts['path'];
+ if (isset($rel_parts['path'])) {
+ if (strpos($rel_parts['path'], '/') !== 0)
+ $rel_parts['path'] = '/' . $rel_parts['path'];
- $rel_parts['path'] = str_replace("/./", "/", $rel_parts['path']);
- $rel_parts['path'] = str_replace("//", "/", $rel_parts['path']);
+ $rel_parts['path'] = str_replace("/./", "/", $rel_parts['path']);
+ $rel_parts['path'] = str_replace("//", "/", $rel_parts['path']);
+ }
return self::validate(self::build_url($rel_parts));
}