Commit 1866533e authored by justcoding121's avatar justcoding121 Committed by justcoding121

update logic

parent 9904f66e
...@@ -60,31 +60,15 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -60,31 +60,15 @@ namespace Titanium.Web.Proxy.Helpers
/// <returns></returns> /// <returns></returns>
internal static string GetWildCardDomainName(string hostname) internal static string GetWildCardDomainName(string hostname)
{ {
/*all needed domain in lower case*/ //only for subdomains we need wild card
/*for now just hard code most common ones */ //example www.google.com or gstatic.google.com
string[] col = { ".com", ".net", ".org", //but NOT for google.com
".cn", ".us", ".in", if (hostname.Split(ProxyConstants.DotSplit).Length > 2)
".co.uk", ".co.in", ".co.us"
};
foreach (string name in col)
{ {
if (hostname.EndsWith(name)) int idx = hostname.IndexOf(ProxyConstants.DotSplit);
{ var rootDomain = hostname.Substring(idx + 1);
int idx = hostname.LastIndexOf(name); return "*." + rootDomain;
int sec = hostname.Substring(0, idx - 1).LastIndexOf('.');
//only for subdomains we need wild card
//example www.google.com or gstatic.google.com
//but NOT for google.com
if(hostname.Substring(0, sec + 1).Contains("."))
{
var rootDomain = hostname.Substring(sec + 1);
return "*." + rootDomain;
}
break;
}
} }
//return as it is //return as it is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment