Skip to content

Commit 25ee991

Browse files
authored
Use Replace helper when converting backslashes (#97582)
1 parent 72bbfb3 commit 25ee991

File tree

1 file changed

+5
-4
lines changed
  • src/libraries/System.Private.Uri/src/System

1 file changed

+5
-4
lines changed

src/libraries/System.Private.Uri/src/System/Uri.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,6 +4548,11 @@ private static void Compress(char[] dest, int start, ref int destLength, UriPars
45484548
//
45494549
private static int Compress(Span<char> span, UriParser syntax)
45504550
{
4551+
if (syntax.InFact(UriSyntaxFlags.ConvertPathSlashes))
4552+
{
4553+
span.Replace('\\', '/');
4554+
}
4555+
45514556
int slashCount = 0;
45524557
int lastSlash = 0;
45534558
int dotCount = 0;
@@ -4556,10 +4561,6 @@ private static int Compress(Span<char> span, UriParser syntax)
45564561
for (int i = span.Length - 1; i >= 0; i--)
45574562
{
45584563
char ch = span[i];
4559-
if (ch == '\\' && syntax.InFact(UriSyntaxFlags.ConvertPathSlashes))
4560-
{
4561-
span[i] = ch = '/';
4562-
}
45634564

45644565
// compress multiple '/' for file URI
45654566
if (ch == '/')

0 commit comments

Comments
 (0)