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

Function normalizeSSODomain

apps/sim/lib/auth/sso/domain.ts:7–28  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

5 * not a registrable domain (e.g. `example.com`), which callers treat as invalid.
6 */
7export function normalizeSSODomain(input: string): string | null {
8 if (typeof input !== 'string') return null
9
10 let value = input.trim().toLowerCase()
11 if (!value) return null
12
13 value = value.replace(/^[a-z][a-z0-9+.-]*:\/\//, '')
14 value = value.replace(/^\*\./, '').replace(/^@/, '')
15 value = value.split('/')[0]
16 value = value.split('?')[0]
17 value = value.split('@').pop() ?? value
18 value = value.split(':')[0]
19 value = value.replace(/\.$/, '')
20
21 if (!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(value)) return null
22
23 const labels = value.split('.')
24 if (labels.some((label) => label.length === 0 || label.length > 63)) return null
25 if (/^\d+$/.test(labels[labels.length - 1])) return null
26
27 return value
28}

Callers 2

domain.test.tsFile · 0.90
route.tsFile · 0.90

Calls 2

testMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected