Differential D16100 Diff 38740 src/applications/repository/data/PhabricatorRepositoryURINormalizer.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/data/PhabricatorRepositoryURINormalizer.php
| Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | /* -( Normalizing URIs )--------------------------------------------------- */ | ||||
| /** | /** | ||||
| * @task normal | * @task normal | ||||
| */ | */ | ||||
| public function getPath() { | public function getPath() { | ||||
| switch ($this->type) { | switch ($this->type) { | ||||
| case self::TYPE_GIT: | case self::TYPE_GIT: | ||||
| $uri = new PhutilURI($this->uri); | $uri = new PhutilURI($this->uri); | ||||
| if ($uri->getProtocol()) { | |||||
| return $uri->getPath(); | |||||
| } | |||||
| $uri = new PhutilGitURI($this->uri); | |||||
| if ($uri->getDomain()) { | |||||
| return $uri->getPath(); | return $uri->getPath(); | ||||
| } | |||||
| return $this->uri; | |||||
| case self::TYPE_SVN: | case self::TYPE_SVN: | ||||
| case self::TYPE_MERCURIAL: | case self::TYPE_MERCURIAL: | ||||
| $uri = new PhutilURI($this->uri); | $uri = new PhutilURI($this->uri); | ||||
| if ($uri->getProtocol()) { | if ($uri->getProtocol()) { | ||||
| return $uri->getPath(); | return $uri->getPath(); | ||||
| } | } | ||||
| return $this->uri; | return $this->uri; | ||||
| Show All 32 Lines | public function getNormalizedPath() { | ||||
| return $path; | return $path; | ||||
| } | } | ||||
| public function getNormalizedDomain() { | public function getNormalizedDomain() { | ||||
| $domain = null; | $domain = null; | ||||
| $uri = new PhutilURI($this->uri); | $uri = new PhutilURI($this->uri); | ||||
| if ($uri->getProtocol()) { | |||||
| $domain = $uri->getDomain(); | |||||
| } | |||||
| if (!strlen($domain)) { | |||||
| $uri = new PhutilGitURI($this->uri); | |||||
| $domain = $uri->getDomain(); | $domain = $uri->getDomain(); | ||||
| } | |||||
| if (!strlen($domain)) { | if (!strlen($domain)) { | ||||
| $domain = '<void>'; | $domain = '<void>'; | ||||
| } | } | ||||
| return phutil_utf8_strtolower($domain); | return phutil_utf8_strtolower($domain); | ||||
| } | } | ||||
| } | } | ||||