From 05d18ae7889c76a98450276a61dd02f3b429bf54 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 22 Dec 2025 22:26:45 -0600 Subject: [PATCH] normalizeUrl belongs in a separate utils file --- src/components/ExternalFavicon.tsx | 3 ++- src/lib/faviconUrl.ts | 17 +---------------- src/lib/url.ts | 14 ++++++++++++++ src/pages/DeploySettings.tsx | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 src/lib/url.ts diff --git a/src/components/ExternalFavicon.tsx b/src/components/ExternalFavicon.tsx index 1538d2df..7a067913 100644 --- a/src/components/ExternalFavicon.tsx +++ b/src/components/ExternalFavicon.tsx @@ -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'; diff --git a/src/lib/faviconUrl.ts b/src/lib/faviconUrl.ts index 666738d6..59c2bfcf 100644 --- a/src/lib/faviconUrl.ts +++ b/src/lib/faviconUrl.ts @@ -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}`; -} +} \ No newline at end of file diff --git a/src/lib/url.ts b/src/lib/url.ts new file mode 100644 index 00000000..3206fda2 --- /dev/null +++ b/src/lib/url.ts @@ -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}`; +} diff --git a/src/pages/DeploySettings.tsx b/src/pages/DeploySettings.tsx index 0db12bf4..73484f6c 100644 --- a/src/pages/DeploySettings.tsx +++ b/src/pages/DeploySettings.tsx @@ -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;