Skip to content

[Bug]: 2 letters domains are not supported #39

@stncrn

Description

@stncrn

Environment

domain-locker.com (managed instance)

Version

demo

Describe the Issue

Hello,

I decided to try the demo before installing the app in Docker.
And I found an issue with one and two letters domains, allowed by some registries, for example: ta.ma, a.fr, hp.com
(.ma allows 2+ letters, .fr allows 1+ letters, .com now allows 3+ letters, but choosed to not revoke 1 and 2 letters domains registered earlier)

The Add Domain form just considers these domains as invalid: " Please enter a valid domain name."

The root cause lies here :

Validators.pattern(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z]{2,})+$/),

The regex /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z]{2,})+$/ should be replaced by a more robust one.

Some googling led me to : ^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$
Which also handles properly other cases that yours misses. (examples from https://regexr.com/8hlkq vs https://regexr.com/8hlkt)

Image

It still isn't perfect however, as it doesn't handles unicode tlds (as .网‍站), even in their punycode form (xn--5tzm5g)
(official full list of TLDs available here : https://data.iana.org/TLD/tlds-alpha-by-domain.txt)
Punycoded domains are properly handled though, for example http://xn--itacos-i50d.ws/ (punycode of http://i❤️tacos.ws)

Logs

No response

System

No response

Before submitting

  • I have clearly described the issue and included all relevant information
  • I have checked the documentation for a solution
  • I have confirmed that this issue has not already been reported
  • I have redacted any sensitive information from logs or debug data
  • I agree to follow the Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions