()
| 57 | } |
| 58 | |
| 59 | // Reads the script body from the DOM. html-validate 9 removed the plugin |
| 60 | // `setup(source)` hook this used to slice the raw source with, after which |
| 61 | // the rule silently checked nothing. |
| 62 | setup() { |
| 63 | this.on("dom:ready", event => { |
| 64 | event.document.querySelectorAll('script[type="application/ld+json"]').forEach(script => { |
| 65 | try { |
| 66 | JSON.parse(script.textContent); |
| 67 | } catch (err) { |
| 68 | this.report(script, `Unable to parse JSON-LD as JSON: ${err}`); |
| 69 | } |
| 70 | }); |
| 71 | }); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // Pages that are not indexed on their own: alias redirects (meta refresh) and |
| 76 | // pages marked noindex. The static link-checker workaround pages and other |
| 77 | // files without a canonical link are not pages search engines should list. |
| 78 | function isIndexablePage (document) { |
| 79 | if (document.querySelector('meta[http-equiv="refresh"]') !== null) return false; |
| 80 | const robots = document.querySelector('meta[name="robots"]'); |
| 81 | if (robots !== null && robots.hasAttribute('content') && /noindex/i.test(robots.getAttribute('content').value)) return false; |
| 82 | return document.querySelector('link[rel="canonical"]') !== null; |
| 83 | } |
| 84 |
nothing calls this directly
no outgoing calls
no test coverage detected