MCPcopy
hub / github.com/FlowiseAI/Flowise / extractChatflowId

Function extractChatflowId

packages/server/src/utils/domainValidation.ts:68–86  ·  view source on GitHub ↗

* Extracts chatflow ID from prediction URL * @param url - The request URL * @returns string | null - The chatflow ID or null if not found

(url: string)

Source from the content-addressed store, hash-verified

66 * @returns string | null - The chatflow ID or null if not found
67 */
68function 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

Callers 1

getCorsOptionsFunction · 0.90

Calls 1

extractSlugFromUrlFunction · 0.85

Tested by

no test coverage detected