HostString does not validate value
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Describe the bug
The `HostString(string value)` constructor does not validate the value. If the value is not a valid `hostname` or `hostname:port`, it would be nice if the `HostString` constructor would throw, instead of just parsing based on the `:` character. This could help prevent unintentional bugs when passing something like a full URL to `HostString`.
### To Reproduce
```C#
var hostString = new HostString("https://example.org");
Console.WriteLine($"hostString.Host: {hostString.Host}");
Console.WriteLine($"hostString.Port: {hostString.Port}");
```
Output:
```
hostString.Host: https
hostString.Port:
```
Expected: Throw an exception.
### Further technical details
- `Microsoft.AspNetCore.Http.Abstractions` version `2.2.0`
Contributor guide
Assessment
This issue has not been assessed yet.