normalizeUrl belongs in a separate utils file

This commit is contained in:
Alex Gleason committed 2025-12-22 22:26:45 -06:00
1 parent ac8fe4108a
commit 05d18ae788
4 files changed
+18 -18

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
import { useAppContext } from '@/hooks/useAppContext';
import { faviconUrl, normalizeUrl } from '@/lib/faviconUrl';
import { faviconUrl } from '@/lib/faviconUrl';
import { normalizeUrl } from '@/lib/url';
import { cn } from '@/lib/utils';
import { ReactNode, useMemo } from 'react';
+1 -16
View File
@@ -22,19 +22,4 @@ export function faviconUrl(template: string, url: string | URL): string {
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}`;
}
}
+14
View File
@@ -0,0 +1,14 @@
/**
* 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}`;
}
+1 -1
View File
@@ -44,7 +44,7 @@ import { useIsMobile } from '@/hooks/useIsMobile';
import { useNavigate, Link } from 'react-router-dom';
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
import { ExternalFavicon } from '@/components/ExternalFavicon';
import { normalizeUrl } from '@/lib/faviconUrl';
import { normalizeUrl } from '@/lib/url';
interface PresetProvider {
id: string;