(url: string | undefined)
| 1 | export function isValidImageUrl(url: string | undefined): boolean { |
| 2 | if (!url) return false; |
| 3 | |
| 4 | // Filter out known problematic URLs |
| 5 | const problematicPatterns = [ |
| 6 | 'lookaside.instagram.com', |
| 7 | 'google_widget/crawler', |
| 8 | '/seo/', |
| 9 | ]; |
| 10 | |
| 11 | if (problematicPatterns.some(pattern => url.includes(pattern))) { |
| 12 | return false; |
| 13 | } |
| 14 | |
| 15 | // For Firecrawl image search results, trust the imageUrl they provide |
| 16 | // These are already validated image URLs from their search |
| 17 | try { |
| 18 | const urlObj = new URL(url); |
| 19 | // Basic validation - must be http/https |
| 20 | if (urlObj.protocol === 'http:' || urlObj.protocol === 'https:') { |
| 21 | return true; |
| 22 | } |
| 23 | } catch { |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | export function getFallbackIcon(): string { |
| 31 | // Return a data URL for a simple globe icon as fallback |
no outgoing calls
no test coverage detected