MCPcopy Index your code
hub / github.com/simstudioai/sim / parseOriginList

Function parseOriginList

apps/sim/lib/core/utils/urls.ts:124–145  ·  view source on GitHub ↗
(
  raw: string | undefined | null,
  onInvalid?: (value: string) => void
)

Source from the content-addressed store, hash-verified

122 * @param onInvalid - Optional callback invoked once per invalid entry
123 */
124export function parseOriginList(
125 raw: string | undefined | null,
126 onInvalid?: (value: string) => void
127): string[] {
128 if (!raw) return []
129 const seen = new Set<string>()
130 const origins: string[] = []
131 for (const candidate of raw.split(',')) {
132 const trimmed = candidate.trim()
133 if (!trimmed) continue
134 try {
135 const { origin } = new URL(trimmed)
136 if (!seen.has(origin)) {
137 seen.add(origin)
138 origins.push(origin)
139 }
140 } catch {
141 onInvalid?.(trimmed)
142 }
143 }
144 return origins
145}
146
147/**
148 * Returns true when the given URL points at a localhost loopback host.

Callers 2

auth.tsFile · 0.90
urls.test.tsFile · 0.90

Calls 3

onInvalidFunction · 0.85
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected