MCPcopy Create free account
hub / github.com/massCodeIO/massCode / buildPreviewUrl

Function buildPreviewUrl

src/renderer/components/http/requestPreview.ts:40–69  ·  view source on GitHub ↗
(draft: HttpRequestDraft)

Source from the content-addressed store, hash-verified

38}
39
40function buildPreviewUrl(draft: HttpRequestDraft): string {
41 const queryString = buildQueryString(draft.query)
42
43 try {
44 const url = new URL(draft.url)
45 if (draft.query.length > 0) {
46 url.search = ''
47 for (const entry of draft.query) {
48 if (entry.enabled === false)
49 continue
50 if (entry.key) {
51 url.searchParams.append(entry.key, entry.value)
52 }
53 }
54 }
55 return url.toString()
56 }
57 catch {
58 if (!queryString) {
59 return draft.url
60 }
61
62 const parts = splitUrl(draft.url)
63 return (
64 parts.path
65 + (queryString ? `?${queryString}` : '')
66 + (parts.fragment || '')
67 )
68 }
69}
70
71function getHttpUrlParts(url: string): { host: string, target: string } {
72 try {

Callers 2

buildHttpPreviewFunction · 0.85
buildCurlPreviewFunction · 0.85

Calls 2

buildQueryStringFunction · 0.70
splitUrlFunction · 0.70

Tested by

no test coverage detected