public static CompositeData ParseComposite(Uri uri)
{
CompositeData rc = new CompositeData();
rc.Scheme = uri.Scheme;
// Start with original URI
//String ssp = uri.Authority + uri.PathAndQuery;
String ssp = uri.OriginalString;
ssp = StripPrefix(ssp, rc.Scheme + ":");
ssp = StripPrefix(ssp, "//");
int lastPoundPos = ssp.LastIndexOf("#");
int lastParendPos = ssp.LastIndexOf(")");
// Only include a Fragment that's outside any Composte sections.
if(lastPoundPos > lastParendPos)
{
rc.Fragment = ssp.Substring(lastPoundPos);
ssp = ssp.Substring(0, lastPoundPos);
}
// Ensure any embedded URIs don't have malformed authority's by changing
// them from '://(' which would cause the .NET Uri class to attempt to validate
// the authority as a hostname with, ':(' which is valid.
ssp = ssp.Replace("://(", ":(");
// Handle the composite components
ParseComposite(uri, rc, ssp);
return rc;
}