This repository was archived by the owner on Sep 28, 2026. It is now read-only.
Repository navigation
seo: add canonical URLs to the five public pages (finding 6631c0ab0454) #29
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1282,6 +1282,59 @@ for (const [pageName, pageHtml] of internalLinkPages) { | |
| } | ||
| } | ||
|
|
||
| // ---- Canonical URLs (dogfood) ---------------------------------------------- | ||
| // The leak audit this site sells also flags a homepage whose served HTML | ||
| // carries no canonical URL, leaving search engines to guess which address is | ||
| // the page (finding 6631c0ab0454, "Missing canonical URL on home"), so the | ||
| // site's own five public pages must not carry that fault either. Each page | ||
| // keeps exactly one <link rel="canonical"> — parsed across the whole document, | ||
| // ignoring commented-out markup and accepting single or double quotes — that | ||
| // link sits inside the head and points at the absolute https://tinystudio.io | ||
| // address the page is served under (the .html form; the worker also serves | ||
| // extensionless twins). | ||
| const canonicalPages = [ | ||
| ["homepage", siteHome, "https://tinystudio.io/"], | ||
| ["audit page", siteAudit, "https://tinystudio.io/audit.html"], | ||
| ["desk page", read("public/agents.html"), "https://tinystudio.io/agents.html"], | ||
| ["pricing page", read("public/pricing.html"), "https://tinystudio.io/pricing.html"], | ||
| ["specimen page", read("public/specimen.html"), "https://tinystudio.io/specimen.html"] | ||
| ]; | ||
|
|
||
| const canonicalLinkPattern = /<link\b[^>]*\brel\s*=\s*["']canonical["'][^>]*>/gi; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a page retains the expected tag but gains a conflicting tag such as Useful? React with 👍 / 👎. |
||
| const canonicalHrefPattern = /\bhref\s*=\s*["']([^"']*)["']/i; | ||
|
|
||
| const seenCanonicals = new Map(); | ||
| for (const [pageName, pageHtml, expected] of canonicalPages) { | ||
| // A commented-out canonical is inert markup; it must neither satisfy the | ||
| // guarantee nor trip the duplicate check. | ||
| const liveHtml = pageHtml.replace(/<!--[\s\S]*?-->/g, ""); | ||
| const links = [...liveHtml.matchAll(canonicalLinkPattern)].map((match) => match[0]); | ||
| if (links.length !== 1) { | ||
| failures.push(`Canonical link must appear exactly once across ${pageName} (found ${links.length}).`); | ||
| continue; | ||
| } | ||
| const head = liveHtml.match(/<head[^>]*>([\s\S]*?)<\/head>/i)?.[1] ?? ""; | ||
| const headLinks = [...head.matchAll(canonicalLinkPattern)].length; | ||
| if (headLinks !== 1) { | ||
| failures.push(`Canonical link on ${pageName} must sit inside the head (found ${headLinks} in head, ${links.length} total).`); | ||
| } | ||
| const href = links[0].match(canonicalHrefPattern)?.[1] ?? ""; | ||
| const trimmed = href.trim(); | ||
| if (!trimmed) { | ||
| failures.push(`Canonical link on ${pageName} must not have an empty href.`); | ||
| continue; | ||
| } | ||
| if (trimmed !== expected) { | ||
| failures.push(`Canonical link on ${pageName} must point at ${expected} (found ${trimmed}).`); | ||
| } | ||
| const prior = seenCanonicals.get(trimmed); | ||
| if (prior) { | ||
| failures.push(`Canonical URL on ${pageName} must be unique; it duplicates ${prior}.`); | ||
| } else { | ||
| seenCanonicals.set(trimmed, pageName); | ||
| } | ||
| } | ||
|
|
||
| for (const migration of ["migrations/0002_agent_runs.sql", "migrations/0003_agent_usage_limits.sql"]) { if (!existsSync(new URL(`../${migration}`, import.meta.url))) { | ||
| failures.push(`Missing migration: ${migration}`); | ||
| continue; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When search engines crawl these four pages, the new guard forces each canonical to its
.htmladdress even though the internal-link guard immediately above identifies those addresses as redirecting and names/audit,/agents,/pricing, and/specimenas the final clean destinations. Canonical URLs should point directly to those final URLs; otherwise every secondary page emits a canonical-to-redirect signal, and this check prevents correcting the tags.Useful? React with 👍 / 👎.