Skip to content

Commit a10c107

Browse files
committed
so optimal
1 parent dfb6062 commit a10c107

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,10 @@ bool IsLocalhost(string host, out string? prefix)
154154
// Check for use of .localhost TLD (Top Level Domain)
155155
if (host.EndsWith(".localhost", StringComparison.OrdinalIgnoreCase))
156156
{
157-
var localhostTldIndex = host.LastIndexOf('.');
158-
if (localhostTldIndex > 0)
157+
if (host.LastIndexOf('.') > 0)
159158
{
160159
// Take all but the .localhost TLD as the prefix
161-
prefix = host[..localhostTldIndex];
160+
prefix = host[..^10]; // 10 is the length of ".localhost"
162161
return true;
163162
}
164163
}

0 commit comments

Comments
 (0)