Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
[release/2.0.0] Revert "Minor change to avoid an allocation in Uri" (#…
Browse files Browse the repository at this point in the history
…25643)

* Revert "Minor change to avoid an allocation in Uri"

This reverts commit 9d73c93.

* Add URI regression test for combining absolute/relative URIs
  • Loading branch information
rmkerr authored and davidsh committed Jan 3, 2018
1 parent 0933a23 commit 97ce4b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/System.Private.Uri/src/System/Uri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,11 @@ private static unsafe ParsingError GetCombinedString(Uri baseUri, string relativ
// Hence anything like x:sdsd is a relative path and be added to the baseUri Path
break;
}
fixed (char* sptr = relativeStr) // relativeStr.Substring(0, i) represents the scheme
string scheme = relativeStr.Substring(0, i);
fixed (char* sptr = scheme)
{
UriParser syntax = null;
if (CheckSchemeSyntax(sptr, (ushort)i, ref syntax) == ParsingError.None)
if (CheckSchemeSyntax(sptr, (ushort)scheme.Length, ref syntax) == ParsingError.None)
{
if (baseUri.Syntax == syntax)
{
Expand Down
7 changes: 7 additions & 0 deletions src/System.Private.Uri/tests/FunctionalTests/UriTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -889,5 +889,12 @@ public static void TestGetComponentParts()
s = uri.GetComponents(UriComponents.Host, UriFormat.UriEscaped);
Assert.Equal(s, "www.contoso.com");
}

[Fact]
public static void TestCasingWhenCombiningAbsoluteAndRelativeUris()
{
Uri u = new Uri(new Uri("http://example.com/", UriKind.Absolute), new Uri("C(B:G", UriKind.Relative));
Assert.Equal("http://example.com/C(B:G", u.ToString());
}
}
}

0 comments on commit 97ce4b6

Please sign in to comment.