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

Function splitUrl

src/renderer/composables/spaces/http/urlQuery.ts:8–20  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

6}
7
8export function splitUrl(url: string): {
9 path: string
10 query: string
11 fragment: string
12} {
13 const hashIdx = url.indexOf('#')
14 const fragment = hashIdx === -1 ? '' : url.slice(hashIdx)
15 const beforeHash = hashIdx === -1 ? url : url.slice(0, hashIdx)
16 const qIdx = beforeHash.indexOf('?')
17 const path = qIdx === -1 ? beforeHash : beforeHash.slice(0, qIdx)
18 const query = qIdx === -1 ? '' : beforeHash.slice(qIdx + 1)
19 return { path, query, fragment }
20}
21
22function combineUrl(parts: {
23 path: string

Callers 3

applyQueryToUrlFunction · 0.70
stripQueryFromUrlFunction · 0.70
applyUrlToQueryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected