mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-25 06:22:19 +00:00
fix(domain): allow single-label hostnames without a TLD
This commit is contained in:
@@ -9,6 +9,9 @@ describe("VALID_HOSTNAME_REGEX", () => {
|
|||||||
"a.b.c.example.co",
|
"a.b.c.example.co",
|
||||||
"xn--80ak6aa92e.com",
|
"xn--80ak6aa92e.com",
|
||||||
"123.example.com",
|
"123.example.com",
|
||||||
|
"example",
|
||||||
|
"dokploy-server",
|
||||||
|
"localhost",
|
||||||
])("accepts valid hostname %s", (host) => {
|
])("accepts valid hostname %s", (host) => {
|
||||||
expect(VALID_HOSTNAME_REGEX.test(host)).toBe(true);
|
expect(VALID_HOSTNAME_REGEX.test(host)).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -17,7 +20,6 @@ describe("VALID_HOSTNAME_REGEX", () => {
|
|||||||
"bbn_client.example.com",
|
"bbn_client.example.com",
|
||||||
"-example.com",
|
"-example.com",
|
||||||
"example-.com",
|
"example-.com",
|
||||||
"example",
|
|
||||||
"exa mple.com",
|
"exa mple.com",
|
||||||
"example..com",
|
"example..com",
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Valid hostname per RFC 1123: labels of letters, digits and hyphens
|
// Valid hostname per RFC 1123: labels of letters, digits and hyphens
|
||||||
// (no leading/trailing hyphen), separated by dots. Underscores are rejected
|
// (no leading/trailing hyphen), optionally separated by dots. Underscores are rejected
|
||||||
// because Let's Encrypt refuses to issue certificates for them.
|
// because Let's Encrypt refuses to issue certificates for them.
|
||||||
export const VALID_HOSTNAME_REGEX =
|
export const VALID_HOSTNAME_REGEX =
|
||||||
/^(?:[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])?$/;
|
/^(?:[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])?$/;
|
||||||
|
|
||||||
export const INVALID_HOSTNAME_MESSAGE =
|
export const INVALID_HOSTNAME_MESSAGE =
|
||||||
"Invalid domain name. Use only letters, numbers, hyphens and dots (e.g. example.com). Underscores are not allowed.";
|
"Invalid domain name. Use only letters, numbers, hyphens and dots (e.g. example.com). Underscores are not allowed.";
|
||||||
|
|||||||
Reference in New Issue
Block a user