Merge pull request #319 from bokub/feature/favicon

Add favicon to websites
This commit is contained in:
Mike Cao authored and GitHub committed 2020-10-21 15:53:48 -07:00
commit 8021d9d3fa
10 files changed
+151 -114

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import React from 'react';
import styles from './Favicon.module.css';
function getHostName(url) {
const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?=]+)/im);
return match && match.length > 1 ? match[1] : null;
}
export default function Favicon({ domain, ...props }) {
const hostName = domain ? getHostName(domain) : null;
return hostName ? (
<img
className={styles.favicon}
src={`https://icons.duckduckgo.com/ip3/${hostName}.ico`}
height="16"
alt=""
{...props}
/>
) : null;
}
+3
View File
@@ -0,0 +1,3 @@
.favicon {
margin-right: 8px;
}