Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33cdfd77cf | |||
| a072a86436 | |||
| 52a5737806 | |||
| 4b10a142c9 |
57
README.md
57
README.md
@@ -13,36 +13,45 @@ Alternativelly you can copy and reference the assembly resulting of the project
|
||||
### VAR.UrlCompressor
|
||||
Add the resulting assembly as reference in your projects, and this line on code:
|
||||
|
||||
using VAR.UrlCompressor;
|
||||
```csharp
|
||||
using VAR.UrlCompressor;
|
||||
```
|
||||
|
||||
Compress an URL with:
|
||||
|
||||
string compressedUrl = UrlCompressor.Compress("https:\\google.com");
|
||||
// compressedUrl = "Hk30TGDxt8jOOW6"
|
||||
```csharp
|
||||
string compressedUrl = UrlCompressor.Compress("https:\\google.com");
|
||||
// compressedUrl = "Hk30TGDxt8jOOW6"
|
||||
```
|
||||
|
||||
Decompress an URL with:
|
||||
|
||||
string decompressedUrl = UrlCompressor.Decompress("Hk30TGDxt8jOOW6");
|
||||
// decompressedUrl = "Hk30TGDxt8jOOW6";
|
||||
```csharp
|
||||
string decompressedUrl = UrlCompressor.Decompress("Hk30TGDxt8jOOW6");
|
||||
// decompressedUrl = "https:\\google.com";
|
||||
```
|
||||
|
||||
For extra compression use host conversions. For example:
|
||||
|
||||
Dictionary<string, string> hostConversions = new Dictionary<string, string> {
|
||||
```csharp
|
||||
Dictionary<string, string> hostConversions = new Dictionary<string, string> {
|
||||
{ "google", "G" }
|
||||
{ "com", "C" }
|
||||
}
|
||||
string compressedUrl = UrlCompressor.Compress("https:\\google.com", );
|
||||
// compressedUrl = "oMyuFVR41"
|
||||
}
|
||||
string compressedUrl = UrlCompressor.Compress("https:\\google.com", );
|
||||
// compressedUrl = "oMyuFVR41"
|
||||
string decompressedUrl = UrlCompressor.Decompress("oMyuFVR41");
|
||||
// decompressedUrl = "https:\\google.com";
|
||||
```
|
||||
|
||||
|
||||
### UrlCompressor.Tests
|
||||
It is a simple console application, to test basic funcitionallity of the library.
|
||||
|
||||
## Building
|
||||
A Visual Studio 2017 solution is provided. Simply, click build on the IDE.
|
||||
A Visual Studio solution is provided. Simply, click build on the IDE.
|
||||
|
||||
A .nuget package can be build using:
|
||||
VAR.UrlCompressor\Build.NuGet.cmd
|
||||
The build generates a DLL and a Nuget package.
|
||||
|
||||
## Contributing
|
||||
1. Fork it!
|
||||
@@ -53,27 +62,3 @@ A .nuget package can be build using:
|
||||
|
||||
## Credits
|
||||
* Valeriano Alfonso Rodriguez.
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2017 Valeriano Alfonso Rodriguez
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UrlCompressor.Tests
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
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, Dictionary<string, string> _hostConversions)
|
||||
{
|
||||
Console.WriteLine("---------------------------------------------");
|
||||
Console.WriteLine(" Url: {0}", url);
|
||||
string compressedUrl = VAR.UrlCompressor.UrlCompressor.Compress(url, _hostConversions);
|
||||
Console.WriteLine(" CompressedUrl: {0}", compressedUrl);
|
||||
string decompressedUrl = VAR.UrlCompressor.UrlCompressor.Decompress(compressedUrl, _hostConversions);
|
||||
Console.WriteLine("DecompressedUrl: {0}", decompressedUrl);
|
||||
if(url!= decompressedUrl)
|
||||
{
|
||||
Console.WriteLine("!!!!! Failed !!!!!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// La información general de un ensamblado se controla mediante el siguiente
|
||||
// conjunto de atributos. Cambie estos valores de atributo para modificar la información
|
||||
// asociada con un ensamblado.
|
||||
[assembly: AssemblyTitle("UrlCompressor.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UrlCompressor.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles
|
||||
// para los componentes COM. Si es necesario obtener acceso a un tipo en este ensamblado desde
|
||||
// COM, establezca el atributo ComVisible en true en este tipo.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM.
|
||||
[assembly: Guid("29d6812a-566d-4a92-a7a4-fc6ae0b3db39")]
|
||||
|
||||
// La información de versión de un ensamblado consta de los cuatro valores siguientes:
|
||||
//
|
||||
// Versión principal
|
||||
// Versión secundaria
|
||||
// Número de compilación
|
||||
// Revisión
|
||||
//
|
||||
// Puede especificar todos los valores o utilizar los números de compilación y de revisión predeterminados
|
||||
// mediante el carácter '*', como se muestra a continuación:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{29D6812A-566D-4A92-A7A4-FC6AE0B3DB39}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>UrlCompressor.Tests</RootNamespace>
|
||||
<AssemblyName>UrlCompressor.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VAR.UrlCompressor\VAR.UrlCompressor.csproj">
|
||||
<Project>{016ae05d-12af-40c6-8d0c-064970004f0b}</Project>
|
||||
<Name>VAR.UrlCompressor</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
328
VAR.UrlCompressor.Tests/UrlCompressorTests.cs
Normal file
328
VAR.UrlCompressor.Tests/UrlCompressorTests.cs
Normal file
@@ -0,0 +1,328 @@
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace VAR.UrlCompressor.Tests
|
||||
{
|
||||
public class UrlCompressorTests
|
||||
{
|
||||
#region Helpers
|
||||
|
||||
private Dictionary<string, string> GenerateHostsConversions()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = new Dictionary<string, string> {
|
||||
{ "com", "C" },
|
||||
{ "net", "N" },
|
||||
{ "org", "O" },
|
||||
{ "localhost", "L" },
|
||||
{ "azurewebsites", "A" },
|
||||
{ "unifikas", "U" },
|
||||
{ "cyc", "Y" },
|
||||
{ "es", "E" },
|
||||
{ "google", "G" },
|
||||
{ "facebook", "F" },
|
||||
{ "twitter", "T" },
|
||||
{ "github", "GH" },
|
||||
{ "varstudio", "V" },
|
||||
};
|
||||
return hostConversions;
|
||||
}
|
||||
|
||||
#endregion Helpers
|
||||
|
||||
#region Compress
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://google.com";
|
||||
string compressedUrl = "zBUW9UxS1";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://google.com";
|
||||
string compressedUrl = "oMyuFVR41";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://facebook.com";
|
||||
string compressedUrl = "EAyWnGuy0";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://facebook.com";
|
||||
string compressedUrl = "2AyutHOa0";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Twitter_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com";
|
||||
string compressedUrl = "bpzuhuDB1";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Twitter_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com/Kableado";
|
||||
string compressedUrl = "zYfD7gXd8ApW9HZtR4";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Github_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://github.com/Kableado";
|
||||
string compressedUrl = "JzJv5CTnllbrEVp1BhF";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Localhost_30000_0()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Http_Localhost_30000_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Unifikas_Azurewebsites_Net_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|1";
|
||||
string compressedUrl = "7R15qGtuLPGD";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Unifikas_Azurewebsites_Net_2()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|2";
|
||||
string compressedUrl = "7B54q0pvLPKC";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compress__Https_Varstudio_Net()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://varstudio.net";
|
||||
string compressedUrl = "5B1u05oK";
|
||||
|
||||
string result = UrlCompressor.Compress(url, hostConversions);
|
||||
|
||||
Assert.Equal(compressedUrl, result);
|
||||
}
|
||||
|
||||
#endregion Compress
|
||||
|
||||
#region Decompress
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://google.com";
|
||||
string compressedUrl = "zBUW9UxS1";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Google_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://google.com";
|
||||
string compressedUrl = "oMyuFVR41";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://facebook.com";
|
||||
string compressedUrl = "EAyWnGuy0";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Facebook_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://facebook.com";
|
||||
string compressedUrl = "2AyutHOa0";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Twitter_Com()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com";
|
||||
string compressedUrl = "bpzuhuDB1";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Twitter_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://twitter.com/Kableado";
|
||||
string compressedUrl = "zYfD7gXd8ApW9HZtR4";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Github_Com_Kableado()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://github.com/Kableado";
|
||||
string compressedUrl = "JzJv5CTnllbrEVp1BhF";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Localhost_30000_0()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Http_Localhost_30000_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "http://localhost:30000|0";
|
||||
string compressedUrl = "0fT4k50uE3WwvqMB42";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Unifikas_Azurewebsites_Net_1()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|1";
|
||||
string compressedUrl = "7R15qGtuLPGD";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Unifikas_Azurewebsites_Net_2()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://unifikas.azurewebsites.net|2";
|
||||
string compressedUrl = "7B54q0pvLPKC";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decompress__Https_Varstudio_Net()
|
||||
{
|
||||
Dictionary<string, string> hostConversions = GenerateHostsConversions();
|
||||
string url = "https://varstudio.net";
|
||||
string compressedUrl = "5B1u05oK";
|
||||
|
||||
string result = UrlCompressor.Decompress(compressedUrl, hostConversions);
|
||||
|
||||
Assert.Equal(url, result);
|
||||
}
|
||||
|
||||
#endregion Decompress
|
||||
}
|
||||
}
|
||||
26
VAR.UrlCompressor.Tests/VAR.UrlCompressor.Tests.csproj
Normal file
26
VAR.UrlCompressor.Tests/VAR.UrlCompressor.Tests.csproj
Normal file
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VAR.UrlCompressor\VAR.UrlCompressor.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,34 +1,37 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26430.15
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31402.337
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.UrlCompressor", "VAR.UrlCompressor\VAR.UrlCompressor.csproj", "{016AE05D-12AF-40C6-8D0C-064970004F0B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UrlCompressor.Tests", "UrlCompressor.Tests\UrlCompressor.Tests.csproj", "{29D6812A-566D-4A92-A7A4-FC6AE0B3DB39}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Notes", "Notes", "{C6BD1525-8B61-4E6A-8146-A18B4468842E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
LICENSE.txt = LICENSE.txt
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VAR.UrlCompressor.Tests", "VAR.UrlCompressor.Tests\VAR.UrlCompressor.Tests.csproj", "{845C1853-EB77-45DA-8388-A7A4F866B3EE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Debug|Any CPU.ActiveCfg = Debug .Net 4.6.1|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Debug|Any CPU.Build.0 = Debug .Net 4.6.1|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Release|Any CPU.ActiveCfg = Release .Net 4.6.1|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Release|Any CPU.Build.0 = Release .Net 4.6.1|Any CPU
|
||||
{29D6812A-566D-4A92-A7A4-FC6AE0B3DB39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{29D6812A-566D-4A92-A7A4-FC6AE0B3DB39}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{29D6812A-566D-4A92-A7A4-FC6AE0B3DB39}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{29D6812A-566D-4A92-A7A4-FC6AE0B3DB39}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{016AE05D-12AF-40C6-8D0C-064970004F0B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{845C1853-EB77-45DA-8388-A7A4F866B3EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{845C1853-EB77-45DA-8388-A7A4F866B3EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{845C1853-EB77-45DA-8388-A7A4F866B3EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{845C1853-EB77-45DA-8388-A7A4F866B3EE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1843DBAF-8D99-42B8-A5AE-D44A48FAFD71}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("VAR.UrlCompressor")]
|
||||
[assembly: AssemblyDescription(".Net library for compressing URLs")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("VAR")]
|
||||
[assembly: AssemblyProduct("VAR.UrlCompressor")]
|
||||
[assembly: AssemblyCopyright("Copyright © VAR 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("016ae05d-12af-40c6-8d0c-064970004f0b")]
|
||||
[assembly: AssemblyVersion("1.1.*")]
|
||||
@@ -1,74 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{016AE05D-12AF-40C6-8D0C-064970004F0B}</ProjectGuid>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VAR.UrlCompressor</RootNamespace>
|
||||
<AssemblyName>VAR.UrlCompressor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug .Net 4.6.1|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net461\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release .Net 4.6.1|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\net461\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug .Net 3.5|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\net35\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release .Net 3.5|AnyCPU'">
|
||||
<OutputPath>bin\Release\net35\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<PropertyGroup>
|
||||
<PackageId>VAR.UrlCompressor</PackageId>
|
||||
<Title>VAR.UrlCompressor</Title>
|
||||
<Version>1.2.0</Version>
|
||||
<Description>.Net library for compressing URLs</Description>
|
||||
<Authors>VAR</Authors>
|
||||
<Company>VAR</Company>
|
||||
<Copyright>Copyright © VAR 2016-2017</Copyright>
|
||||
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
|
||||
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://github.com/Kableado/VAR.UrlCompressor</PackageProjectUrl>
|
||||
<PackageTags>URL Compression Library</PackageTags>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Content Include="..\LICENSE.txt" Link="LICENSE.txt" Pack="true" PackagePath=""/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base62.cs" />
|
||||
<Compile Include="ByteExtensions.cs" />
|
||||
<Compile Include="Huffman.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UrlCompressor.cs" />
|
||||
<Compile Include="Url.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Build.NuGet.cmd" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="VAR.UrlCompressor.nuspec" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||
<Copy
|
||||
SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg"
|
||||
DestinationFolder="Nuget\"
|
||||
/>
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user