Skip to content

Fix domain validation rejecting valid domains (#113)#114

Merged
shigahi merged 1 commit into
masterfrom
fix/domain-validation-113
Jun 16, 2026
Merged

Fix domain validation rejecting valid domains (#113)#114
shigahi merged 1 commit into
masterfrom
fix/domain-validation-113

Conversation

@shigahi

@shigahi shigahi commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

Closes #113.

isValidDomain rejected several valid domains, e.g.:

  • test.app1e.com — a subdomain label containing a digit
  • short labels like x.io

Root cause

The previous regex only allowed alphanumerics in the first label and restricted every following label to letters only ((?:\.[a-zA-Z]{2,})+). So any non-first / non-TLD label containing a digit (app1e) was rejected, and the first label was forced to be at least 3 characters.

/^((https:\/\/)|(http:\/\/))?[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+(\/)?$/

Fix

Validate each label independently (alphanumeric plus hyphens, no leading/trailing hyphen, max 63 chars) and restrict only the TLD to letters:

/^(https?:\/\/)?([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}\/?$/

Verification

  • Now valid: test.app1e.com, app1e.kr, x.io, a.b.c.example.com, 1example.com, https://test.app1e.com, example.co.uk
  • Still rejected: ``, example., `-bad.com`, `bad-.com`, `a..b.com`, `example.123`
  • npm run build passes

Validate each domain label independently (alphanumeric plus hyphens,
not leading/trailing) and restrict only the TLD to letters. Fixes
domains like test.app1e.com being rejected.

Closes #113
@shigahi shigahi merged commit c10b0bf into master Jun 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some domains are invalidated in worknot.classmethod.live

1 participant