MCPcopy Create free account
hub / github.com/cameri/nostream / normalizePathPrefix

Function normalizePathPrefix

src/utils/http.ts:65–84  ·  view source on GitHub ↗
(pathPrefix: string | undefined)

Source from the content-addressed store, hash-verified

63}
64
65const normalizePathPrefix = (pathPrefix: string | undefined): string => {
66 if (typeof pathPrefix !== 'string') {
67 return ''
68 }
69
70 const prefix = pathPrefix.split(',')[0].trim()
71
72 if (!prefix.startsWith('/') || prefix.startsWith('//')) {
73 return ''
74 }
75
76 try {
77 const { pathname } = new URL(prefix, 'http://nostream.local')
78 const normalized = pathname.replace(/\/+$/, '')
79
80 return normalized === '/' ? '' : normalized
81 } catch {
82 return ''
83 }
84}
85
86const getRelayUrlPathPrefix = (relayUrl: string | undefined): string => {
87 if (typeof relayUrl !== 'string') {

Callers 2

getRelayUrlPathPrefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected