* Extracts chatflow ID from prediction URL * @param url - The request URL * @returns string | null - The chatflow ID or null if not found
(url: string)
| 66 | * @returns string | null - The chatflow ID or null if not found |
| 67 | */ |
| 68 | function extractChatflowId(url: string): string | null { |
| 69 | try { |
| 70 | const urlParts = url.split('/') |
| 71 | const slug = extractSlugFromUrl(url) |
| 72 | if (!slug) return null |
| 73 | const slugIndex = urlParts.indexOf(slug) |
| 74 | |
| 75 | if (slugIndex !== -1 && urlParts.length > slugIndex + 1) { |
| 76 | const chatflowId = urlParts[slugIndex + 1] |
| 77 | // Remove query parameters if present |
| 78 | return chatflowId.split('?')[0] |
| 79 | } |
| 80 | |
| 81 | return null |
| 82 | } catch (error) { |
| 83 | logger.error('Error extracting chatflow ID from URL:', error) |
| 84 | return null |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Extracts the slug from the URL if it matches any of the allowed slugs |
no test coverage detected