Is It Technically/Feasibly Possible for a URL to have 3 or More Public Suffix Labels? (eg. test.co.io.example)

I know that it's possible to have at least 2 labels in the publix suffix (eg. test.co.example), but is it possible to have 3 or more (eg. test.co.jp.example)? I'm not asking if it's possible to have multiple domain names, rather just the suffix in the URL alone (eg. .com).

If it's not possible, why?


Yes, domains with more than 3 labels are common, this is most obvious in educational context, where URLs often look like https://me.institute.place.university.edu.cctld.

(The term TLD is only used to refer to the (singular) topmost level, so this answer assumes the question is about properties of the entire suffix, not actually about multiple TLDs.)

More examples can be found in the public suffix list - if the level at which you start registering already has 3 labels (e.g. .shinshiro.aichi.jp) then websites which are structured internally can end up even longer.

The technical limitations of how many labels there could be in a valid URL are way beyond what is practical, and more than 3 are still very much common and practical. There are no specific limitations about any of the labels matching something also used as a top level domain. Hard limits include the 255 character limit on lookups (meaning no more than 127 labels separated by dots).

I'm writing a function that will strip a URL of its parts except for the domain name

In general, please don't reinvent that wheel - existing libraries have this function and have thought of more edge cases than you and I possibly could. Instead, focus on what you do with the results, e.g. how you ensure that your users work with or see with domains in a manner avoiding ambiguity or getting defrauded.

Even if an URL was perfectly valid and common in real world settings, you still might only display it partially (show fake.example instead of https://serverfault.com.fake.example/login) or refuse to run certain features for uncommon URLS (to avoid participating in DoS).