MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / normalizeHttpUrl

Method normalizeHttpUrl

src/main/api/renderer/webSearch.ts:372–383  ·  view source on GitHub ↗
(rawUrl: string)

Source from the content-addressed store, hash-verified

370 }
371
372 private normalizeHttpUrl(rawUrl: string): { success: boolean; url?: string } {
373 const candidate = this.ensureUrlProtocol(rawUrl.trim())
374 try {
375 const parsed = new URL(candidate)
376 if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
377 return { success: false }
378 }
379 return { success: true, url: parsed.toString() }
380 } catch {
381 return { success: false }
382 }
383 }
384
385 private ensureUrlProtocol(url: string): string {
386 if (/^https?:\/\//i.test(url)) {

Callers 1

Calls 1

ensureUrlProtocolMethod · 0.95

Tested by

no test coverage detected