mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 21:27:20 +01:00
24 lines
543 B
TypeScript
24 lines
543 B
TypeScript
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 }) {
|
|
if (process.env.privateMode) {
|
|
return null;
|
|
}
|
|
|
|
const hostName = domain ? getHostName(domain) : null;
|
|
|
|
return hostName ? (
|
|
<img
|
|
src={`https://icons.duckduckgo.com/ip3/${hostName}.ico`}
|
|
width={16}
|
|
height={16}
|
|
alt=""
|
|
{...props}
|
|
/>
|
|
) : null;
|
|
}
|
|
|
|
export default Favicon;
|