mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Allow custom favicon URL. Closes #3365
This commit is contained in:
parent
ffa8d8dd88
commit
02f0df3a2e
3 changed files with 14 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { GROUPED_DOMAINS } from '@/lib/constants';
|
||||
import { FAVICON_URL, GROUPED_DOMAINS } from '@/lib/constants';
|
||||
|
||||
function getHostName(url: string) {
|
||||
const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n?=]+)/im);
|
||||
|
|
@ -10,10 +10,10 @@ export function Favicon({ domain, ...props }) {
|
|||
return null;
|
||||
}
|
||||
|
||||
const url = process.env.faviconURL || FAVICON_URL;
|
||||
const hostName = domain ? getHostName(domain) : null;
|
||||
const src = hostName
|
||||
? `https://icons.duckduckgo.com/ip3/${GROUPED_DOMAINS[hostName]?.domain || hostName}.ico`
|
||||
: null;
|
||||
const domainName = GROUPED_DOMAINS[hostName]?.domain || hostName;
|
||||
const src = hostName ? url.replace(/\{\{\s*domain\s*}}/, domainName) : null;
|
||||
|
||||
return hostName ? <img src={src} width={16} height={16} alt="" {...props} /> : null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue