Do host name checking the same way in back- and frontend

This commit is contained in:
Hylke Bons 2011-05-22 19:08:14 +01:00
parent 748a54652f
commit 4d6ea9d707
2 changed files with 22 additions and 8 deletions

View file

@ -53,7 +53,7 @@ namespace SparkleLib {
public string Domain {
get {
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)/");
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)(/|:)");
Match match = regex.Match (Url);
if (match.Success)

View file

@ -968,12 +968,14 @@ namespace SparkleShare {
{
SparkleHelpers.DebugInfo ("Controller", "Formed URL: " + url);
// TODO: GetDomain method
string host = url.Substring (url.IndexOf ("@") + 1);
if (host.Contains (":"))
host = host.Substring (0, host.IndexOf (":"));
else
host = host.Substring (0, host.IndexOf ("/"));
string host = GetHost (url);
if (String.IsNullOrEmpty (host)) {
if (FolderFetchError != null)
FolderFetchError ();
return;
}
DisableHostKeyCheckingForHost (host);
@ -1053,7 +1055,19 @@ namespace SparkleShare {
Byte[] encoded_bytes = md5.ComputeHash (bytes);
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
}
private string GetHost (string url)
{
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)(/|:)");
Match match = regex.Match (url);
if (match.Success)
return match.Groups [2].Value;
else
return null;
}
// Checks whether there are any folders syncing and
// quits if safe