(html: string)
| 442 | } |
| 443 | |
| 444 | function stripHostJsxRuntimeScripts(html: string): string { |
| 445 | return transformHtmlElementBlocks(html, 'script', ({ attrs, tag }) => { |
| 446 | const rawSrc = getHtmlAttribute(attrs, 'src'); |
| 447 | if (rawSrc === null) return tag; |
| 448 | let url: URL; |
| 449 | try { |
| 450 | url = new URL(rawSrc); |
| 451 | } catch { |
| 452 | return tag; |
| 453 | } |
| 454 | return isKnownHostJsxRuntimePath(url.pathname) ? '' : tag; |
| 455 | }); |
| 456 | } |
| 457 | |
| 458 | function isKnownHostJsxRuntimePath(path: string): boolean { |
| 459 | const parts = path.toLowerCase().split('/').filter(Boolean); |
no test coverage detected