(attrs: string)
| 237 | |
| 238 | /** Whether a `<script>` element's attributes leave it JavaScript: no `type`, or a JavaScript one. */ |
| 239 | export function isJavaScriptBlock(attrs: string): boolean { |
| 240 | const type = /\btype\s*=\s*["']([^"']*)["']/i.exec(attrs)?.[1]?.trim().toLowerCase(); |
| 241 | if (type === undefined || type === '') return true; |
| 242 | return /^(?:module|(?:text|application)\/(?:javascript|ecmascript|typescript|babel|jsx)|text\/(?:x-)?(?:babel|jsx))$/.test(type); |
| 243 | } |
no test coverage detected