[MS] How is the Windows.Foundation.Uri.Domain property different from Host? - devamazonaws.blogspot.com

The Windows Runtime class Windows.Foundation.Uri has two string properties: Host and Domain. What's the difference?

Let's start with Host. This is the "host" as defined in RFC 3986 which defines the syntax for URIs.

Okay, that was easy. What about Domain?

The Domain is an attempt to identify the part of the Host that was registered with a top-level domain (TLD) registrar.

Host Domain
example.com example.com
mail.example.com example.com
www.bbc.co.uk bbc.co.uk
bbc.co.uk bbc.co.uk

The code for the Domain property applies a bunch of rules to determine how many levels of the fully-qualified domain name should be used to determine the "domain".

The problem is that the authority for these rules is "whoever runs the TLD". We see that different TLDs have different policies: The .com TLD allows organizations to register second-level domains, whereas the .uk TLD registers organizations as third-level domains, under .co.uk. There is no standard for how each TLD assigns its domains; each TLD can choose whatever pattern it likes.

What's more, there's no requirement that a TLD stick to the pattern it chose originally, or even have a pattern at all. For example, the .br TLD (waves hello in Brazilian Portuguese) originally registered organizations under the third level, so you got names like contoso.com.br, but it then decided to allow organizations (primarily universities) to register as second-level domains. This means that if you are given a domain under .br, you have to look at the second-level domain and see if it's on a list of known reserved second-level domains such as com.br for commercial organizations or slg.br for (checks notes) sociologists. If so, then the third-level domain is the organizational domain; otherwise, you have an organization that was granted a second-level domain.

There are over 100 defined reserved second-level domains under .br, and I suspect that the list has grown even longer while I was sleeping. It's practically impossible to keep up with all of these changes in TLD policy around the world, so what you get from the Domain property is a best-guess at the organizational domain. And at least for the .br TLD, it's definitely not completely up to date. For example, it thinks that the organizational domain for mail.contoso.tec.br is tec.br instead of contoso.tec.br.

So what is Domain good for?

I'm not sure. It's trying its best, but the world is too complicated.


Post Updated on August 29, 2024 at 03:00PM
Thanks for reading
from devamazonaws.blogspot.com

Comments

Popular posts from this blog

Scenarios capability now generally available for Amazon Q in QuickSight - devamazonaws.blogspot.com

[MS] Introducing Pull Request Annotation for CodeQL and Dependency Scanning in GitHub Advanced Security for Azure DevOps - devamazonaws.blogspot.com

AWS Console Mobile Application adds support for Amazon Lightsail - devamazonaws.blogspot.com