Add external provider icons with favicons

This commit is contained in:
Alex Gleason committed 2025-10-21 13:53:00 -05:00
1 parent 2e68c54dbe
commit 71f82ed717
15 files changed
+300 -89

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import UriTemplate from 'uri-templates';
/**
* Generate a favicon URL from a template and input URL
* @param template - URL template with placeholders like {hostname}, {origin}, etc.
* @param url - The URL to extract parts from
* @returns The hydrated favicon URL
*/
export function faviconUrl(template: string, url: string | URL): string {
const u = new URL(url);
return UriTemplate(template).fill({
href: u.href,
origin: u.origin,
protocol: u.protocol,
username: u.username,
password: u.password,
host: u.host,
hostname: u.hostname,
port: u.port,
pathname: u.pathname,
hash: u.hash,
search: u.search,
});
}
/**
* Normalize a URL string to ensure it has a protocol
* @param url - The URL string to normalize
* @returns A fully-qualified URL string
*/
export function normalizeUrl(url: string): string {
// If it already has a protocol, return as-is
if (/^https?:\/\//i.test(url)) {
return url;
}
// Add https:// prefix
return `https://${url}`;
}