MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / readAttr

Function readAttr

packages/lint/src/utils.ts:125–134  ·  view source on GitHub ↗
(tagSource: string, attr: string)

Source from the content-addressed store, hash-verified

123}
124
125export function readAttr(tagSource: string, attr: string): string | null {
126 if (!tagSource) return null;
127 const escaped = attr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
128 // `(?<![\w-])` not `\b`: a plain `\b` boundary treats the hyphen in a longer
129 // attribute as a word break, so reading "id" would wrongly match the trailing
130 // `id="…"` inside `data-hf-id="…"` (and "width" inside `data-width`, etc.).
131 // The lookbehind requires the match to start a fresh attribute name.
132 const match = tagSource.match(new RegExp(`(?<![\\w-])${escaped}\\s*=\\s*["']([^"']+)["']`, "i"));
133 return match?.[1] || null;
134}
135
136/**
137 * Read an attribute that may legitimately contain the opposite quote

Callers 15

extractMediaUrlsFunction · 0.90
buildLintContextFunction · 0.90
parseTimingFunction · 0.90
media.tsFile · 0.90
classNamesFunction · 0.90
hasInlineMaskImageFunction · 0.90
hasInlineDropShadowFunction · 0.90
textures.tsFile · 0.90
isStudioTimelineElementFunction · 0.90
describeStudioElementFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected