MCPcopy
hub / github.com/firecrawl/fireplexity / isValidImageUrl

Function isValidImageUrl

lib/image-utils.ts:1–28  ·  view source on GitHub ↗
(url: string | undefined)

Source from the content-addressed store, hash-verified

1export 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
30export function getFallbackIcon(): string {
31 // Return a data URL for a simple globe icon as fallback

Callers 3

SearchResultsFunction · 0.90
NewsResultsFunction · 0.90
ImageResultsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected