Skip to content

Commit

Permalink
Merge pull request #397 from sinamics/domain-validation
Browse files Browse the repository at this point in the history
Update domain validation to allow subdomains
  • Loading branch information
sinamics authored May 8, 2024
2 parents e667287 + 59d7540 commit 141714a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/api/utils/ipUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ export function isValidIP(ip: string): boolean {
* @returns `true` if the domain is valid, `false` otherwise.
*/
export function isValidDomain(domain: string): boolean {
const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/;
const domainRegex = /^(?!-)[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
return domainRegex.test(domain);
}

0 comments on commit 141714a

Please sign in to comment.