diff --git a/src/components/ExternalFavicon.tsx b/src/components/ExternalFavicon.tsx index 7a067913..38868387 100644 --- a/src/components/ExternalFavicon.tsx +++ b/src/components/ExternalFavicon.tsx @@ -1,12 +1,11 @@ import { useAppContext } from '@/hooks/useAppContext'; import { faviconUrl } from '@/lib/faviconUrl'; -import { normalizeUrl } from '@/lib/url'; import { cn } from '@/lib/utils'; import { ReactNode, useMemo } from 'react'; interface ExternalFaviconProps { /** The URL to fetch the favicon for */ - url: string; + url: string | URL; /** Size of the favicon in pixels */ size?: number; /** Fallback element to display if favicon fails to load */ @@ -31,8 +30,7 @@ export function ExternalFavicon({ const faviconSrc = useMemo(() => { try { // Normalize the URL to ensure it has a protocol - const normalizedUrl = normalizeUrl(url); - return faviconUrl(config.faviconUrl, normalizedUrl); + return faviconUrl(config.faviconUrl, url); } catch { return; } diff --git a/src/components/git-sync/steps/SyncStep.tsx b/src/components/git-sync/steps/SyncStep.tsx index a1db6de6..afea7124 100644 --- a/src/components/git-sync/steps/SyncStep.tsx +++ b/src/components/git-sync/steps/SyncStep.tsx @@ -208,19 +208,11 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) { // Check if we have a matched credential const matchedCredential = findCredentialsForRepo(remoteUrl, settings.credentials); - if (matchedCredential) { - return { - name: matchedCredential.name, - icon: ( - - ), - }; - } - return { name: remoteUrl.hostname }; + return { + name: matchedCredential? matchedCredential.name : remoteUrl.hostname, + icon: , + }; }, [remoteUrl, settings.credentials]); const providerInfo = getProviderInfo(); diff --git a/src/lib/url.ts b/src/lib/url.ts deleted file mode 100644 index 3206fda2..00000000 --- a/src/lib/url.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * 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 25b99f80..fb565853 100644 --- a/src/pages/DeploySettings.tsx +++ b/src/pages/DeploySettings.tsx @@ -44,7 +44,6 @@ import { useCurrentUser } from '@/hooks/useCurrentUser'; import { Link } from 'react-router-dom'; import type { DeployProvider } from '@/contexts/DeploySettingsContext'; import { ExternalFavicon } from '@/components/ExternalFavicon'; -import { normalizeUrl } from '@/lib/url'; interface PresetProvider { id: string; @@ -377,6 +376,22 @@ function generateCustomProviderId(type: string): string { return `${type}-${randomSegment}`; } +/** + * Normalize a URL string to ensure it has a protocol + * @param url - The URL string to normalize + * @returns A fully-qualified URL string + */ +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}`; +} + + function getProviderUrl(provider: DeployProvider | PresetProvider): string | null { switch (provider.type) { case 'shakespeare':