//Code inspired by Rasmus Faber's solution in this post: http://stackoverflow.com/questions/781205/getting-a-url-with-an-url-encoded-slash public void Purify(Uri uri) { if (!uri.IsAbsoluteUri) { return; } string paq = uri.PathAndQuery; // need to access PathAndQuery string abs = uri.AbsoluteUri; //need to access this as well the MoreInfo prop is initialized. var flags = (ulong)flagsField.GetValue(uri); flags &= ~((ulong)0x30); // Flags.PathNotCanonical|Flags.QueryNotCanonical flagsField.SetValue(uri, flags); object info = infoField.GetValue(uri); var source = (string)stringField.GetValue(uri); infoStringField.SetValue(info, source); object moreInfo = moreInfoField.GetValue(info); moreInfoAbsoluteUri.SetValue(moreInfo, source); var uriInfo = new UriInfo(uri, source); moreInfoPath.SetValue(moreInfo, uriInfo.Path); moreInfoQuery.SetValue(moreInfo, uriInfo.Query); }
public void Purify(Uri uri) { var source = (string)mono_sourceField.GetValue(uri); var uriInfo = new UriInfo(uri, source); mono_pathField.SetValue(uri, uriInfo.Path.StartsWith("/") ? uriInfo.Path : "/" + uriInfo.Path ); mono_queryField.SetValue(uri, uriInfo.Query); mono_cachedToStringField.SetValue(uri, uriInfo.Source); mono_cachedAbsoluteUriField.SetValue(uri, uriInfo.Source); }