MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / isValidURL

Function isValidURL

packages/components/src/validator.ts:22–32  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

20 * single quotes, backticks (template literals), backslashes, and newlines.
21 */
22export const isValidURL = (url: string): boolean => {
23 try {
24 const parsed = new URL(url)
25 if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false
26 if (parsed.hash) return false
27 if (/["'`\\\n\r\t]/.test(url)) return false
28 return true
29 } catch {
30 return false
31 }
32}
33
34/**
35 * Validates if a string contains path traversal attempts

Callers 6

initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
runMethod · 0.90
validator.test.tsFile · 0.90
assertSafeServerUrlFunction · 0.50

Calls 1

testMethod · 0.80

Tested by

no test coverage detected