UrlCompressor: Use typical host names for extra reduction. Can be user defined.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UrlCompressor.Tests
|
||||
{
|
||||
@@ -6,25 +7,31 @@ namespace UrlCompressor.Tests
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
TestUrl("http://google.com");
|
||||
TestUrl("https://google.com");
|
||||
TestUrl("http://facebook.com");
|
||||
TestUrl("https://facebook.com");
|
||||
TestUrl("https://twitter.com");
|
||||
TestUrl("https://twitter.com/Kableado");
|
||||
TestUrl("https://github.com/Kableado");
|
||||
TestUrl("https://varstudio.net");
|
||||
Dictionary<string, string> _hostConversions = new Dictionary<string, string> {
|
||||
{ "com", "C" },
|
||||
{ "net", "N" },
|
||||
{ "org", "O" },
|
||||
};
|
||||
|
||||
TestUrl("http://google.com", _hostConversions);
|
||||
TestUrl("https://google.com", _hostConversions);
|
||||
TestUrl("http://facebook.com", _hostConversions);
|
||||
TestUrl("https://facebook.com", _hostConversions);
|
||||
TestUrl("https://twitter.com", _hostConversions);
|
||||
TestUrl("https://twitter.com/Kableado", _hostConversions);
|
||||
TestUrl("https://github.com/Kableado", _hostConversions);
|
||||
TestUrl("https://varstudio.net", _hostConversions);
|
||||
|
||||
Console.Read();
|
||||
}
|
||||
|
||||
private static bool TestUrl(string url)
|
||||
private static bool TestUrl(string url, Dictionary<string, string> _hostConversions)
|
||||
{
|
||||
Console.WriteLine("---------------------------------------------");
|
||||
Console.WriteLine(" Url: {0}", url);
|
||||
string compressedUrl = VAR.UrlCompressor.UrlCompressor.Compress(url);
|
||||
string compressedUrl = VAR.UrlCompressor.UrlCompressor.Compress(url, _hostConversions);
|
||||
Console.WriteLine(" CompressedUrl: {0}", compressedUrl);
|
||||
string decompressedUrl = VAR.UrlCompressor.UrlCompressor.Decompress(compressedUrl);
|
||||
string decompressedUrl = VAR.UrlCompressor.UrlCompressor.Decompress(compressedUrl, _hostConversions);
|
||||
Console.WriteLine("DecompressedUrl: {0}", decompressedUrl);
|
||||
if(url!= decompressedUrl)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user