mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-06-21 02:12:10 +03:00
fix: allow .tld for user_domains_text & user_domains
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
import { ValidationResult } from './types';
|
||||
|
||||
export function validateDomain(domain: string): ValidationResult {
|
||||
export function validateDomain(
|
||||
domain: string,
|
||||
allowDotTLD = false
|
||||
): ValidationResult {
|
||||
const domainRegex =
|
||||
/^(?=.{1,253}(?:\/|$))(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9-]{1,59}[a-zA-Z0-9])(?:\/[^\s]*)?$/;
|
||||
/^(?=.{1,253}(?:\/|$))(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9-]{1,59}[a-zA-Z0-9])(?:\/[^\s]*)?$/;
|
||||
|
||||
if (allowDotTLD) {
|
||||
const dotTLD = /^\.[a-zA-Z]{2,}$/;
|
||||
if (dotTLD.test(domain)) {
|
||||
return { valid: true, message: _('Valid') };
|
||||
}
|
||||
}
|
||||
|
||||
if (!domainRegex.test(domain)) {
|
||||
return { valid: false, message: _('Invalid domain address') };
|
||||
|
||||
Reference in New Issue
Block a user