diff --git a/src/content/docs/rules/snippets/examples/rewrite-site-links.mdx b/src/content/docs/rules/snippets/examples/rewrite-site-links.mdx index 78a7063352ccc0..e5ea0222bea4d9 100644 --- a/src/content/docs/rules/snippets/examples/rewrite-site-links.mdx +++ b/src/content/docs/rules/snippets/examples/rewrite-site-links.mdx @@ -40,7 +40,13 @@ export default { .on("img", new AttributeRewriter("src")); const res = await fetch(request); + if (!res.headers.has("Content-Type")) { + return res; + } const contentType = res.headers.get("Content-Type"); + if (typeof contentType !== "string") { + return res; + } // If the response is HTML, it can be transformed with // HTMLRewriter -- otherwise, it should pass through @@ -51,4 +57,4 @@ export default { } }, }; -``` \ No newline at end of file +```