Utility functions for cleaning up URL construction issues, particularly handling double slashes and path joining problems common in web applications and storage URLs. ## Key Components - **`fixUrlDoubleSlashes(url: string)`** - Removes consecutive slashes from URLs while preserving protocol slashes (`https://`) - **`joinUrlPath(...segments: string[])`** - Safely joins multiple path segments without creating double slashes - **`fixSupabaseStorageUrl(url: string)`** - Specialized function for fixing Supabase storage URLs that contain the `/storage/v1/object/public/` path pattern ## Usage Example ```typescript import { fixUrlDoubleSlashes, joinUrlPath, fixSupabaseStorageUrl } from './url-fix'; // Fix double slashes in any URL const cleanUrl = fixUrlDoubleSlashes('https://example.com//api//users///123'); // Result: 'https://example.com/api/users/123' // Safely join path segments const apiPath = joinUrlPath('/api/', '/users/', '123/'); // Result: 'api/users/123' // Fix Supabase storage URLs specifically const storageUrl = fixSupabaseStorageUrl('https://app.example.com/storage/v1/object/public/logos///image.png'); // Result: 'https://app.example.com/storage/v1/object/public/logos/image.png' // Combine for robust URL building const baseUrl = 'https://api.example.com/'; const endpoint = joinUrlPath(baseUrl, 'v1', 'users', userId); const cleanEndpoint = fixUrlDoubleSlashes(endpoint); ``` These utilities are particularly useful for preventing SEO issues and ensuring consistent URL formatting across applications that programmatically construct URLs.