-
Notifications
You must be signed in to change notification settings - Fork 0
fix(public): point internal page links at final clean URLs (dogfood 996dffe45ef7) #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1243,6 +1243,45 @@ for (const [pageName, pageHtml, pageUrl] of structuredDataPages) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ---- Internal page links (dogfood 996dffe45ef7) --------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The leak audit this site sells flags a homepage whose internal links do not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // point at the final destination URL: the dogfood run reported every .html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // navigation target on home ("index.html" -> "/", "audit.html" -> "/audit", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // "agents.html" -> "/agents", "pricing.html" -> "/pricing", "specimen.html" -> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // "/specimen") as a redirecting internal link. The five public pages must | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // therefore point every page link at the clean URL the worker serves, never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // at a .html file that resolves to it. These are STATIC SOURCE GUARDS (regex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // over the served files): CI has no browser, so they assert the .html target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // shape cannot return, not that the redirects are absent on the network. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const internalLinkPages = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ["homepage", siteHome], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ["audit page", siteAudit], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ["desk page", read("public/agents.html")], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ["pricing page", read("public/pricing.html")], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ["specimen page", read("public/specimen.html")] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1259
to
+1261
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.
After a successful HTML signup, the worker redirects users to Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const htmlPageTargets = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "index.html": "/", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "audit.html": "/audit", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "agents.html": "/agents", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "pricing.html": "/pricing", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "specimen.html": "/specimen" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const [pageName, pageHtml] of internalLinkPages) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const anchors = [...pageHtml.matchAll(/<a\b[^>]*>/gi)].map((match) => match[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const anchor of anchors) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const href = anchor.match(/\bhref="([^"]*)"/i)?.[1] ?? ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const target = href.split("#")[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (Object.prototype.hasOwnProperty.call(htmlPageTargets, target)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| failures.push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Internal page link on ${pageName} must point at the clean destination ${JSON.stringify(htmlPageTargets[target])} (found ${JSON.stringify(href)}).` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1272
to
+1280
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Normalize href values before checking old page targets. The guard only matches Proposed guard hardening for (const [pageName, pageHtml] of internalLinkPages) {
const anchors = [...pageHtml.matchAll(/<a\b[^>]*>/gi)].map((match) => match[0]);
for (const anchor of anchors) {
- const href = anchor.match(/\bhref="([^"]*)"/i)?.[1] ?? "";
- const target = href.split("#")[0];
+ const hrefMatch = anchor.match(
+ /(?:^|\s)href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'`=<>]+))/i
+ );
+ const href = hrefMatch?.[1] ?? hrefMatch?.[2] ?? hrefMatch?.[3] ?? "";
+ let target;
+ try {
+ const url = new URL(href, "https://tinystudio.io/");
+ if (url.origin !== "https://tinystudio.io") continue;
+ target = url.pathname.replace(/^\/+/, "");
+ } catch {
+ continue;
+ }
if (Object.prototype.hasOwnProperty.call(htmlPageTargets, target)) {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: nish3451/TinyStudio.io
Length of output: 205
🏁 Script executed:
Repository: nish3451/TinyStudio.io
Length of output: 38301
🏁 Script executed:
Repository: nish3451/TinyStudio.io
Length of output: 7647
🏁 Script executed:
Repository: nish3451/TinyStudio.io
Length of output: 19864
🏁 Script executed:
Repository: nish3451/TinyStudio.io
Length of output: 19590
Align public routes and metadata.
The worker serves both route forms, but navigation uses extensionless paths while
og:urland JSON-LDWebPageURLs use.htmlinpublic/audit.html,public/agents.html,public/pricing.html, andpublic/specimen.html. Choose one canonical route scheme and apply it to the navigation, metadata, and related public references.🤖 Prompt for AI Agents