fixed regex rules for validating url

This commit is contained in:
huangjx
2022-02-23 15:42:53 +08:00
parent 938055e6ea
commit 684be80113

View File

@@ -42,10 +42,8 @@ const helper = {
}, delay);
},
isURL(url) {
let regex = '^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@|\\d{1,3}(?:\.\\d{1,3}){3}|(?:(?:[a-z\\d\\u{00a1}-\\u{ffff}'
+ ']+-?)*[a-z\\d\\u{00a1}-\\u{ffff}]+)(?:\.(?:[a-z\\d\\u{00a1}-\\u{ffff}]+-?)*[a-z\\d\\u{00a1}-\\u{ffff}]+)*(?:\.'
+ '[a-z\\u{00a1}-\\u{ffff}]{2,6}))(?::\\d+)?(?:[^\\s]*)?$';
const pattern = new RegExp(regex, 'iu');
let regex = '^((https?|ftp)://)([a-z0-9-]+\.)?(?:[-a-zA-Z0-9()@:%_\+.~#?&/=]+)$';
const pattern = new RegExp(regex, 'i');
return pattern.test(url);
},
isMagnetURI(url) {