Skip to content

Commit 5d231bf

Browse files
committed
fix(domain): allow single-label hostnames without a TLD
1 parent 0124613 commit 5d231bf

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎apps/dokploy/__test__/utils/hostname-validation.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ describe("VALID_HOSTNAME_REGEX", () => {
99
"a.b.c.example.co",
1010
"xn--80ak6aa92e.com",
1111
"123.example.com",
12+
"example",
13+
"dokploy-server",
14+
"localhost",
1215
])("accepts valid hostname %s", (host) => {
1316
expect(VALID_HOSTNAME_REGEX.test(host)).toBe(true);
1417
});
@@ -17,7 +20,6 @@ describe("VALID_HOSTNAME_REGEX", () => {
1720
"bbn_client.example.com",
1821
"-example.com",
1922
"example-.com",
20-
"example",
2123
"exa mple.com",
2224
"example..com",
2325
"",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Valid hostname per RFC 1123: labels of letters, digits and hyphens
2-
// (no leading/trailing hyphen), separated by dots. Underscores are rejected
2+
// (no leading/trailing hyphen), optionally separated by dots. Underscores are rejected
33
// because Let's Encrypt refuses to issue certificates for them.
44
export const VALID_HOSTNAME_REGEX =
5-
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
5+
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
66

77
export const INVALID_HOSTNAME_MESSAGE =
88
"Invalid domain name. Use only letters, numbers, hyphens and dots (e.g. example.com). Underscores are not allowed.";

0 commit comments

Comments
 (0)