Updated types.

This commit is contained in:
Mike Cao committed 2023-11-13 14:12:05 -08:00
1 parent bdf2fa4f05
commit 366ef35d3d
14 files changed
+136 -59

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import styles from './Favicon.module.css';
function getHostName(url: string) {
const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?=]+)/im);
return match && match.length > 1 ? match[1] : null;
}
export 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;
}
export default Favicon;