public virtual string OnQualifyUrl(string url)
{
if (QualifyUrl != null)
{
var q = QualifyUrl(url);
if (q != null)
return url;
}
// Quit if we don't have a base location
if (String.IsNullOrEmpty(UrlBaseLocation))
return url;
// Is the url a fragment?
if (url.StartsWith("#"))
return url;
// Is the url already fully qualified?
if (Utils.IsUrlFullyQualified(url))
return url;
if (url.StartsWith("/"))
{
if (!string.IsNullOrEmpty(UrlRootLocation))
{
return UrlRootLocation + url;
}
// Need to find domain root
int pos = UrlBaseLocation.IndexOf("://");
if (pos == -1)
pos = 0;
else
pos += 3;
// Find the first slash after the protocol separator
pos = UrlBaseLocation.IndexOf('/', pos);
// Get the domain name
string strDomain=pos<0 ? UrlBaseLocation : UrlBaseLocation.Substring(0, pos);
// Join em
return strDomain + url;
}
else
{
if (!UrlBaseLocation.EndsWith("/"))
return UrlBaseLocation + "/" + url;
else
return UrlBaseLocation + url;
}
}