MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / normalizeCustomPropertyBody

Function normalizeCustomPropertyBody

packages/extension/utils/css.ts:966–974  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

964// - DO NOT add "var-" for numeric-leading names (e.g., "--05" is valid)
965// - collapse accidental extra dashes (e.g. var(----foo) -> "--foo")
966export function normalizeCustomPropertyBody(name: string): string {
967 if (!name) return 'var'
968 let raw = name.trim()
969 if (raw.startsWith('--')) raw = raw.slice(2)
970 raw = raw.replace(/^-+/, '')
971 // Remove unsupported characters (Figma's CSS output tends to drop punctuation)
972 raw = raw.replace(/[^A-Za-z0-9_-]/g, '')
973 return raw || 'var'
974}
975
976export function normalizeCustomPropertyName(name: string): string {
977 return `--${normalizeCustomPropertyBody(name)}`

Callers 4

css.test.tsFile · 0.90
collectRefsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected