(key: string, doc?: Document)
| 20 | } |
| 21 | |
| 22 | export function getMetaValue(key: string, doc?: Document): string | undefined { |
| 23 | let ownerWindow = getOwnerWindow(doc); |
| 24 | let ownerDocument = getOwnerDocument(doc); |
| 25 | |
| 26 | if (ownerDocument == null || ownerWindow == null) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | let content: string | undefined = undefined; |
| 31 | let selector = `meta[name="${CSS.escape(key)}"], meta[property="${CSS.escape(key)}"]`; |
| 32 | let meta = ownerDocument.querySelector(selector); |
| 33 | |
| 34 | if (meta && meta instanceof ownerWindow.HTMLMetaElement) { |
| 35 | if (key === 'csp-nonce' && meta.nonce) { |
| 36 | content ??= meta.nonce || undefined; |
| 37 | } |
| 38 | |
| 39 | if (meta.content) { |
| 40 | content ??= meta.content || undefined; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if (key === 'csp-nonce') { |
| 45 | content ??= ownerWindow.__webpack_nonce__ || globalThis.__webpack_nonce__ || undefined; |
| 46 | } |
| 47 | |
| 48 | return content; |
| 49 | } |
no test coverage detected