netbirdio / dashboard

NetBird Management Service Web UI Panel
https://app.netbird.io
BSD 3-Clause "New" or "Revised" License
273 stars 63 forks source link

Fix DNS modal to allow one char domains #393

Closed pascal-fischer closed 4 months ago

pascal-fischer commented 5 months ago

This PR fixes the isValidDomain regex to allow single char domain names like a.bc.com Tested the regex with the following set:

console.log(isValidDomain("p.abc.com")); // true
console.log(isValidDomain("example.com")); // true
console.log(isValidDomain("invalid domain")); // false
console.log(isValidDomain("a..b")); // false
console.log(isValidDomain(".3.v")); // false
console.log(isValidDomain("a-b.com")); // true
console.log(isValidDomain("a.b")); // true
console.log(isValidDomain("ab.bc.de")); // true
console.log(isValidDomain("a-b.dc.de")); // true
console.log(isValidDomain("a--b.com")); // false
console.log(isValidDomain("-abc.com")); // false
console.log(isValidDomain("abc-.com")); // false
console.log(isValidDomain("abc..com")); // false