(name: string, value: string)
| 343 | }; |
| 344 | |
| 345 | const 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. |
no test coverage detected