feat: 网站favicon获取

This commit is contained in:
osiris
2024-03-08 16:16:49 +08:00
parent 6ecafa8bc2
commit 101ee6dff2
9 changed files with 793 additions and 576 deletions
+14
View File
@@ -0,0 +1,14 @@
export function isUrl(str: string): boolean {
// const urlPattern = new RegExp(
// '^(https?:\\/\\/)?'+ // protocol
// '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name and extension
// '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
// '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
// '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
// '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
// return urlPattern.test(str);
const urlPattern = new RegExp(
'^(https?:\\/\\/)?'+ // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,})','i'); // fragment locator
return urlPattern.test(str);
}