Skip to content

Commit 7400e9a

Browse files
committed
Remove duplicated logic in both branches
1 parent fdcd584 commit 7400e9a

File tree

1 file changed

+12
-24
lines changed
  • src/libraries/System.Private.Uri/src/System

1 file changed

+12
-24
lines changed

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

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,12 @@ private void CreateThis(string? uri, bool dontEscape, UriKind uriKind, in UriCre
123123
return GetException(err);
124124
}
125125
}
126-
else if (uriKind == UriKind.Relative)
126+
127+
if (uriKind == UriKind.Relative)
127128
{
128129
// Here we know that we can create an absolute Uri, but the user has requested only a relative one
129130
return GetException(ParsingError.CannotCreateRelative);
130131
}
131-
132-
if (hasUnicode)
133-
{
134-
// In this scenario we need to parse the whole string
135-
try
136-
{
137-
EnsureParseRemaining();
138-
}
139-
catch (UriFormatException ex)
140-
{
141-
return ex;
142-
}
143-
}
144132
}
145133
else
146134
{
@@ -170,18 +158,18 @@ private void CreateThis(string? uri, bool dontEscape, UriKind uriKind, in UriCre
170158
// relative one
171159
return GetException(ParsingError.CannotCreateRelative);
172160
}
161+
}
173162

174-
if (hasUnicode)
163+
if (hasUnicode)
164+
{
165+
// In this scenario we need to parse the whole string
166+
try
175167
{
176-
// In this scenario we need to parse the whole string
177-
try
178-
{
179-
EnsureParseRemaining();
180-
}
181-
catch (UriFormatException ex)
182-
{
183-
return ex;
184-
}
168+
EnsureParseRemaining();
169+
}
170+
catch (UriFormatException ex)
171+
{
172+
return ex;
185173
}
186174
}
187175

0 commit comments

Comments
 (0)