- $scheme = parse_url($this->url, PHP_URL_SCHEME);
- switch ($scheme) {
- case 'git':
- //clearly a git url
- $this->gitUrl = $this->url;
- return true;
-
- case 'ssh':
- //FIXME: maybe loosen this when we know how to skip the
- //"do you trust this server" question of ssh
- $this->error = 'ssh:// URLs are not supported';
- return false;
-
- case 'http':
- case 'https':
- return $this->extractUrlsFromHtml($this->url);
+ $hp = new HtmlParser();
+ $ret = $hp->extractGitUrls($this->url);
+ $this->arGitUrls = $hp->getGitUrls();
+ $this->error = $hp->error;
+
+ return $ret;
+ }
+
+ /**
+ * Iterate through all git urls and return one if there is only
+ * one supported one.
+ *
+ * @return mixed Boolean false or array with keys "url" and "title"
+ */
+ public function getUniqueGitUrl()
+ {
+ $nFound = 0;
+ foreach ($this->arGitUrls as $title => $arUrls) {
+ foreach ($arUrls as $url) {
+ $nFound++;
+ $uniqueUrl = array('url' => $url, 'title' => $title);
+ }