MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / validateURL

Function validateURL

source code/tools/WebFetchTool/utils.ts:141–171  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

139}
140
141export function validateURL(url: string): boolean {
142 if (url.length > MAX_URL_LENGTH) {
143 return false
144 }
145
146 let parsed
147 try {
148 parsed = new URL(url)
149 } catch {
150 return false
151 }
152
153 // We don't need to check protocol here, as we'll upgrade http to https when making the request
154
155 // As long as we aren't supporting aiming to cookies or internal domains,
156 // we should block URLs with usernames/passwords too, even though these
157 // seem exceedingly unlikely.
158 if (parsed.username || parsed.password) {
159 return false
160 }
161
162 // Initial filter that this isn't a privileged, company-internal URL
163 // by checking that the hostname is publicly resolvable
164 const hostname = parsed.hostname
165 const parts = hostname.split('.')
166 if (parts.length < 2) {
167 return false
168 }
169
170 return true
171}
172
173type DomainCheckResult =
174 | { status: 'allowed' }

Callers 1

getURLMarkdownContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected