feat: special ip address 'localhost' (#2935)

This commit is contained in:
Alex Yang
2023-06-30 03:54:24 +00:00
committed by GitHub
parent 4adbe64a54
commit 271ad57160
2 changed files with 8 additions and 3 deletions
+3
View File
@@ -1,4 +1,7 @@
export function isValidIPAddress(address: string) {
if (address === 'localhost') {
return true;
}
return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(
address
);