🐞 fix: 修复网址正则错误

This commit is contained in:
imsyy 2024-01-31 09:26:15 +08:00
parent 2edc0cfd62
commit 71663fd222
No known key found for this signature in database
GPG Key ID: 5D959EAB73CA095D

View File

@ -9,11 +9,17 @@ const identifyInput = (input) => {
* 网址正则
* @type {RegExp}
*/
const urlRegex =
/^(?:(?:(?:https?|ftp):)?\/\/)?(?:\d{1,3}(?:\.\d{1,3}){3}|[a-z0-9-]+\.[a-z]{2,})(?::\d+)?(?:\/[^?\s]*)?$/i;
const ipv4Regex =
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
const urlRegex = new RegExp(
"^(http://www.|https://www.|http://|https://)?[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$",
);
/**
* IP 正则
* @type {RegExp}
*/
const ipv4Regex = new RegExp(
"^(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]?)$",
);
/**
* 邮箱正则