Don't show www. in chevereto or pomf list

This commit is contained in:
Jaex 2016-03-05 18:23:53 +02:00
parent 2e6211648c
commit 6c6ab39cf1
3 changed files with 26 additions and 16 deletions

View file

@ -350,5 +350,27 @@ public static string RemovePrefixes(string url)
return url;
}
public static string GetShortURL(string url)
{
Uri uri;
if (Uri.TryCreate(url, UriKind.Absolute, out uri))
{
string host = uri.Host;
if (!string.IsNullOrEmpty(host))
{
if (host.StartsWith("www.", StringComparison.InvariantCultureIgnoreCase))
{
host = host.Substring(4);
}
return host;
}
}
return url;
}
}
}

View file

@ -23,6 +23,7 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
namespace ShareX.UploadersLib.FileUploaders
@ -44,14 +45,7 @@ public PomfUploader(string uploadURL, string resultURL = null)
public override string ToString()
{
Uri uri;
if (Uri.TryCreate(UploadURL, UriKind.Absolute, out uri))
{
return uri.Host;
}
return UploadURL;
return URLHelpers.GetShortURL(UploadURL);
}
}
}

View file

@ -23,6 +23,7 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Linq;
@ -47,14 +48,7 @@ public CheveretoUploader(string uploadURL, string apiKey)
public override string ToString()
{
Uri uri;
if (Uri.TryCreate(UploadURL, UriKind.Absolute, out uri))
{
return uri.Host;
}
return UploadURL;
return URLHelpers.GetShortURL(UploadURL);
}
}
}