Skip to content

Commit

Permalink
Add support for parsing SourceForge git URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
gdevic committed Jan 17, 2016
1 parent 90f07aa commit 667aed4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ClassURL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ public static Url Parse(string URL)
url.Port = 0;
url.Ok = false;

// URL cannot be empty and cannot have spaces
if (string.IsNullOrEmpty(u) || u.Contains(' '))
return url;

try
{
if (string.IsNullOrEmpty(u))
throw new ArgumentNullException();

// Some formats imply SSH, so do a quick sanity check before assigning it
if (u.Contains(':'))
url.Type = UrlType.Ssh;
Expand Down Expand Up @@ -120,7 +121,7 @@ public static Url Parse(string URL)

// Find the project name
string[] tokens = u.Split(new[] { '\\', '/', '.' });
if (tokens.Length >= 2 && tokens[tokens.Length - 1].ToLower() == "git")
if (tokens.Length >= 2 && (tokens[tokens.Length - 1].ToLower() == "git" || tokens[tokens.Length - 1].ToLower() == "code"))
url.Name = tokens[tokens.Length - 2];
else
url.Name = tokens[tokens.Length - 1];
Expand Down
4 changes: 3 additions & 1 deletion UserControlRemoteDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@ private void BtWwwClick(object sender, EventArgs e)
{
string key = ((Button) sender).Tag.ToString();
ClassUrl.Url url = key == "Fetch" ? _fetchUrl : _pushUrl;
// Find the generic host name
// Find a generic host name
string target = "http://" + url.Host;
// Detect some special hosts for which we can form a complete path
if (url.Host.Contains("github"))
target += "/" + url.Path;
if (url.Host.Contains(".code.sf.net"))
target = "https://sourceforge.net/projects/" + url.Name;
ClassUtils.OpenWebLink(target);
}

Expand Down

0 comments on commit 667aed4

Please sign in to comment.