Changeset View
Changeset View
Standalone View
Standalone View
src/parser/PhutilURI.php
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | public function __toString() { | ||||
if ($this->isGitURI()) { | if ($this->isGitURI()) { | ||||
$protocol = null; | $protocol = null; | ||||
} else { | } else { | ||||
if ($auth !== null) { | if ($auth !== null) { | ||||
$protocol = nonempty($this->protocol, 'http'); | $protocol = nonempty($this->protocol, 'http'); | ||||
} | } | ||||
} | } | ||||
if (strlen($protocol) || strlen($auth) || strlen($domain)) { | $has_protocol = ($protocol !== null) && strlen($protocol); | ||||
$has_auth = ($auth !== null); | |||||
$has_domain = ($domain !== null) && strlen($domain); | |||||
$has_port = ($port !== null) && strlen($port); | |||||
if ($has_protocol || $has_auth || $has_domain) { | |||||
if ($this->isGitURI()) { | if ($this->isGitURI()) { | ||||
$prefix = "{$auth}{$domain}"; | $prefix = "{$auth}{$domain}"; | ||||
} else { | } else { | ||||
$prefix = "{$protocol}://{$auth}{$domain}"; | $prefix = "{$protocol}://{$auth}{$domain}"; | ||||
} | } | ||||
if (strlen($port)) { | if ($has_port) { | ||||
$prefix .= ':'.$port; | $prefix .= ':'.$port; | ||||
} | } | ||||
} | } | ||||
if ($this->query) { | if ($this->query) { | ||||
$query = '?'.phutil_build_http_querystring_from_pairs($this->query); | $query = '?'.phutil_build_http_querystring_from_pairs($this->query); | ||||
} else { | } else { | ||||
$query = null; | $query = null; | ||||
▲ Show 20 Lines • Show All 370 Lines • Show Last 20 Lines |