MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / rewriteLocalRef

Function rewriteLocalRef

packages/core/sdk/src/artifact-preview.ts:345–352  ·  view source on GitHub ↗
(name: string, value: string)

Source from the content-addressed store, hash-verified

343};
344
345const rewriteLocalRef = (name: string, value: string): string => {
346 if (!LOCAL_REF_ATTRIBUTES.has(name)) return value;
347 // `url(#chart-gradient)` -> `url(#artifact-preview-chart-gradient)`. A `url()`
348 // that is not a local fragment is a fetch, so it is dropped entirely.
349 const match = /^url\(['"]?#([^'")]+)['"]?\)$/.exec(value.trim());
350 if (match) return `url(#${PREVIEW_ID_PREFIX}${match[1] ?? ""})`;
351 return /^url\(/i.test(value.trim()) ? "" : value;
352};
353
354/**
355 * Parse one tag's attributes.

Callers 1

sanitizeAttributesFunction · 0.85

Calls 1

execMethod · 0.80

Tested by

no test coverage detected