Skip to content

Open source alternative to Semrush and Ahrefs

Site audits read mixed-case meta description and robots names (EVE-263) (#805)

Carter Smith00bd0e913bd6
diff --git a/src/server/lib/audit/page-analyzer.test.ts b/src/server/lib/audit/page-analyzer.test.ts
index dec451c8..c8ad71a1 100644
--- a/src/server/lib/audit/page-analyzer.test.ts
+++ b/src/server/lib/audit/page-analyzer.test.ts
@@ -208,6 +208,25 @@ describe("analyzeHtml parity with the DOM reference", () => {
});
});
+describe("analyzeHtml meta names are case-insensitive", () => {
+ const analyzeHead = (head: string) =>
+ analyzeHtml(`<head>${head}</head>`, PAGE_URL, 200, 0);
+
+ it("reads the first description regardless of name case", () => {
+ expect(
+ analyzeHead(
+ `<meta name="Description" content="first"><meta name="description" content="second">`,
+ ).metaDescription,
+ ).toBe("first");
+ });
+
+ it("reads robots for name=ROBOTS", () => {
+ expect(
+ analyzeHead(`<meta name="ROBOTS" content="noindex">`).robotsMeta,
+ ).toBe("noindex");
+ });
+});
+
describe("analyzeHtml extraction caps", () => {
it("caps links and images per page", () => {
const links = Array.from(
diff --git a/src/server/lib/audit/page-analyzer.ts b/src/server/lib/audit/page-analyzer.ts
index 7dad80c0..fb50e62d 100644
--- a/src/server/lib/audit/page-analyzer.ts
+++ b/src/server/lib/audit/page-analyzer.ts
@@ -91,9 +91,11 @@ export function analyzeHtml(
const handleMetaTag = (attribs: Record<string, string>) => {
const content = attribs["content"];
- if (attribs["name"] === "description") {
+ // HTML meta names are ASCII case-insensitive: "Description" is valid.
+ const metaName = attribs["name"]?.toLowerCase();
+ if (metaName === "description") {
metaDescription ??= content?.trim() ?? "";
- } else if (attribs["name"] === "robots") {
+ } else if (metaName === "robots") {
robotsMeta ??= content ?? null;
} else if (attribs["property"] === "og:title") {
ogTitle ??= content ?? null;