Skip to content

Commit bab1093

Browse files
committed
Super optimal
1 parent a10c107 commit bab1093

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Servers/Kestrel/Core/src/Internal/AddressBinder.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,12 @@ bool IsLocalhost(string host, out string? prefix)
152152
}
153153

154154
// Check for use of .localhost TLD (Top Level Domain)
155-
if (host.EndsWith(".localhost", StringComparison.OrdinalIgnoreCase))
155+
if (host.EndsWith(".localhost", StringComparison.OrdinalIgnoreCase)
156+
&& !string.Equals(parsedAddress.Host, ".localhost", StringComparison.OrdinalIgnoreCase))
156157
{
157-
if (host.LastIndexOf('.') > 0)
158-
{
159-
// Take all but the .localhost TLD as the prefix
160-
prefix = host[..^10]; // 10 is the length of ".localhost"
161-
return true;
162-
}
158+
// Take all but the .localhost TLD as the prefix
159+
prefix = host[..^10]; // 10 is the length of ".localhost"
160+
return true;
163161
}
164162

165163
prefix = null;

0 commit comments

Comments
 (0)