fix(ssr): allow underscores in host validation#32846
Merged
alan-agius4 merged 1 commit intoangular:mainfrom Mar 27, 2026
Merged
fix(ssr): allow underscores in host validation#32846alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4 merged 1 commit intoangular:mainfrom
Conversation
bb53c3a to
0fe626e
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the VALID_HOST_REGEX to include underscores, enhancing its flexibility for hostname validation. The review feedback suggests a further improvement to make the regex more robust by explicitly validating an optional port and preventing invalid host formats with multiple colons.
0fe626e to
1881a9c
Compare
The VALID_HOST_REGEX has been updated to include the underscore character. This ensures that hostnames containing underscores (e.g., in some internal or development environments) are correctly validated instead of being rejected. Closes angular#32835
1881a9c to
7531034
Compare
dgp1130
approved these changes
Mar 26, 2026
| * Regular expression to validate that the host is a valid hostname. | ||
| */ | ||
| const VALID_HOST_REGEX = /^[a-z0-9.:-]+$/i; | ||
| const VALID_HOST_REGEX = /^[a-z0-9_.-]+(:[0-9]+)?$/i; |
Collaborator
There was a problem hiding this comment.
Question: Can you start a hostname with a -, _, or .? Do we care to be that specific? Might be fine to allow at this layer even if it fails elsewhere.
Collaborator
Author
There was a problem hiding this comment.
No, but this is more of checking for invalid characters.
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The VALID_HOST_REGEX has been updated to include the underscore character. This ensures that hostnames containing underscores (e.g., in some internal or development environments) are correctly validated instead of being rejected.
Closes #32835