#!/usr/bin/env node
/**
* REAL SEO Verification Test
* Tests actual rendered HTML output, not just file existence
*/
const https = require('https');
const http = require('http');
const BASE_URL = 'localhost';
const PORT = 3000;
function fetchPage(path) {
return new Promise((resolve, reject) => {
const req = http.get({ hostname: BASE_URL, port: PORT, path }, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve(data));
});
req.on('error', reject);
req.setTimeout(5000, () => {
req.destroy();
reject(new Error('Timeout'));
});
});
}
function extractMetaTags(html) {
const tags = {};
// Title
const titleMatch = html.match(/
([^<]*)<\/title>/);
if (titleMatch) tags.title = titleMatch[1];
// Meta description
const descMatch = html.match(/]*name="description"[^>]*content="([^"]*)"[^>]*>/);
if (descMatch) tags.description = descMatch[1];
// Meta keywords
const keywordsMatch = html.match(/]*name="keywords"[^>]*content="([^"]*)"[^>]*>/);
if (keywordsMatch) tags.keywords = keywordsMatch[1];
// Canonical
const canonicalMatch = html.match(/]*rel="canonical"[^>]*href="([^"]*)"[^>]*>/);
if (canonicalMatch) tags.canonical = canonicalMatch[1];
// Robots
const robotsMatch = html.match(/]*name="robots"[^>]*content="([^"]*)"[^>]*>/);
if (robotsMatch) tags.robots = robotsMatch[1];
// OpenGraph tags
const ogTitle = html.match(/]*property="og:title"[^>]*content="([^"]*)"[^>]*>/);
if (ogTitle) tags.ogTitle = ogTitle[1];
const ogDesc = html.match(/]*property="og:description"[^>]*content="([^"]*)"[^>]*>/);
if (ogDesc) tags.ogDescription = ogDesc[1];
const ogUrl = html.match(/]*property="og:url"[^>]*content="([^"]*)"[^>]*>/);
if (ogUrl) tags.ogUrl = ogUrl[1];
// Twitter cards
const twitterCard = html.match(/]*name="twitter:card"[^>]*content="([^"]*)"[^>]*>/);
if (twitterCard) tags.twitterCard = twitterCard[1];
return tags;
}
function checkJsonLd(html) {
const schemas = [];
const scriptMatches = html.matchAll(/