Skip to content

Follow-up on IsLocalhost TLD local dev #62838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged

Conversation

ladeak
Copy link
Contributor

@ladeak ladeak commented Jul 21, 2025

IsLocalhost TLD optimization

IsLocalhost avoids capturing closure. Follow up on comment #62593 (comment)

Description

Changed IsLocalhost from an instance method to a static method. Updated the parameter to use host directly instead of parsedAddress.Host. Modified the check for the .localhost TLD to ensure the host length is greater than 10, optimizing the condition to avoid unnecessary checks for shorter hostnames.

It also avoids an additional string comparison, slightly improving the performance (both optimized and non-optimized ([MethodImpl(MethodImplOptions.NoOptimization)] cases), given this code is likely to run a lot with Debug builds.

Fixes #62592

@github-actions github-actions bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jul 21, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 21, 2025
Changed `IsLocalhost` from an instance method to a static method. Updated the parameter to use `host` directly instead of `parsedAddress.Host`. Modified the check for the `.localhost` TLD to ensure the host length is greater than 10, optimizing the condition to avoid unnecessary checks for shorter hostnames.

Fixes dotnet#61155
@BrennanConroy BrennanConroy merged commit 6ab0f4e into dotnet:main Jul 22, 2025
30 checks passed
@BrennanConroy BrennanConroy added this to the 10.0-rc1 milestone Jul 22, 2025
@wtgodbe wtgodbe modified the milestones: 10.0-preview7, 10.0-rc1 Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add *.localhost & *.internal to the dev cert SANs
4 participants