Repository: FlowiseAI/Flowise
File: packages/server/src/index.ts (TypeScript)

Code before:
                for (const checkPath of checkPaths) {
                    if (fs.existsSync(checkPath)) {
                        return checkPath
                    }
                }
                return ''
            }

            const packagejsonPath = getPackageJsonPath()
            if (!packagejsonPath) return res.status(404).send('Version not found')
            try {
                const content = await fs.promises.readFile(packagejsonPath, 'utf8')
                const parsedContent = JSON.parse(content)
                return res.json({ version: parsedContent.version })
            } catch (error) {
                return res.status(500).send(`Version not found: ${error}`)
            }
        })

        // ----------------------------------------
        // Scraper
        // ----------------------------------------

        this.app.get('/api/v1/fetch-links', async (req: Request, res: Response) => {
            const url = decodeURIComponent(req.query.url as string)
            const relativeLinksMethod = req.query.relativeLinksMethod as string
            const limit = parseInt(req.query.limit as string)
            if (process.env.DEBUG === 'true') console.info(`Start ${relativeLinksMethod}`)
            const links: string[] = relativeLinksMethod === 'webCrawl' ? await webCrawl(url, limit) : await xmlScrape(url, limit)

            res.json({ status: 'OK', links })
        })

        // ----------------------------------------
        // Upsert
        // ----------------------------------------

        this.app.post(
            '/api/v1/vector/upsert/:id',
            upload.array('files'),
            (req: Request, res: Response, next: NextFunction) => getRateLimiter(req, res, next),
            async (req: Request, res: Response) => {
                await this.upsertVector(req, res)
            }
        )

        this.app.post('/api/v1/vector/internal-upsert/:id', async (req: Request, res: Response) => {
            await this.upsertVector(req, res, true)
        })

        // ----------------------------------------

Review comment (suggestion):
Check if `relativeLinksMethod` is empty; if so, return an error prompting the user to select a method. 

If not in line 1153: will keep call `xmlScrape`

Code after:
                for (const checkPath of checkPaths) {
                    if (fs.existsSync(checkPath)) {
                        return checkPath
                    }
                }
                return ''
            }

            const packagejsonPath = getPackageJsonPath()
            if (!packagejsonPath) return res.status(404).send('Version not found')
            try {
                const content = await fs.promises.readFile(packagejsonPath, 'utf8')
                const parsedContent = JSON.parse(content)
                return res.json({ version: parsedContent.version })
            } catch (error) {
                return res.status(500).send(`Version not found: ${error}`)
            }
        })

        // ----------------------------------------
        // Scraper
        // ----------------------------------------

        this.app.get('/api/v1/fetch-links', async (req: Request, res: Response) => {
            const url = decodeURIComponent(req.query.url as string)
            const relativeLinksMethod = req.query.relativeLinksMethod as string
            if (!relativeLinksMethod) {
                return res.status(500).send('Please choose a Relative Links Method in Additional Parameters.')
            }

            const limit = parseInt(req.query.limit as string)
            if (process.env.DEBUG === 'true') console.info(`Start ${relativeLinksMethod}`)
            const links: string[] = relativeLinksMethod === 'webCrawl' ? await webCrawl(url, limit) : await xmlScrape(url, limit)
            if (process.env.DEBUG === 'true') console.info(`Finish ${relativeLinksMethod}`)

            res.json({ status: 'OK', links })
        })

        // ----------------------------------------
        // Upsert
        // ----------------------------------------

        this.app.post(
            '/api/v1/vector/upsert/:id',
            upload.array('files'),
            (req: Request, res: Response, next: NextFunction) => getRateLimiter(req, res, next),
            async (req: Request, res: Response) => {
                await this.upsertVector(req, res)
            }
        )