Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions docs/docs-participate/basics/index.md

This file was deleted.

6 changes: 6 additions & 0 deletions docs/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@
to = "/participate/:splat"
status = 301

# The basics overview repeated the Basics list of the Participate overview.
[[redirects]]
from = "/participate/basics"
to = "/participate"
status = 301

# Network → Operate redirect
[[redirects]]
from = "/network/*"
Expand Down
8 changes: 5 additions & 3 deletions docs/netlify/edge-functions/markdown-negotiation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ function toMarkdownPath(pathname) {

const toPagePath = (twinPath) => (twinPath === "/index.md" ? "/" : twinPath.slice(0, -3));

// netlify dev's fetch wrapper re-resolves the path against the site, where `//host/...` names another host.
const namesAnotherHost = (url) => url.pathname.startsWith("//");

/** A bare HEAD to this site that leaves redirects unfollowed; null for a path starting with `//`. */
async function probe(url) {
// netlify dev's fetch wrapper re-resolves the path against the site, where `//host/...` names another host.
if (url.pathname.startsWith("//")) return null;
if (namesAnotherHost(url)) return null;
return fetch(url, { method: "HEAD", redirect: "manual", headers: { accept: "text/html", [SUBREQUEST_HEADER]: "subrequest" } });
}

Expand Down Expand Up @@ -80,7 +82,7 @@ export default async (request, context) => {

const accept = request.headers.get("accept") || "";
if (!prefersMarkdown(accept)) return;
if (FILE.test(url.pathname)) return;
if (FILE.test(url.pathname) || namesAnotherHost(url)) return;

const markdownUrl = new URL(url.toString());
markdownUrl.pathname = toMarkdownPath(url.pathname);
Expand Down
4 changes: 3 additions & 1 deletion docs/netlify/edge-functions/migration-notes-range.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default async (request) => {
if (query.from === null && query.to === null) return;
const problem = queryProblem(query);
if (problem) return badRange(problem);
// netlify dev's fetch wrapper re-resolves the path against the site, where `//host/...` names another host.
if (url.pathname.startsWith("//")) return;

// Assigned, never resolved as a reference: a path that starts with `//` would name another host.
const indexUrl = new URL(url.origin);
Expand All @@ -44,4 +46,4 @@ export default async (request) => {
return reply(200, renderRange(selection, url.origin + url.pathname.replace(/\.md$/, "")), "text/markdown");
};

export const config = { path: "/*/migration_notes.md" };
export const config = { path: "/*/migration_notes.md", onError: "bypass" };
8 changes: 8 additions & 0 deletions docs/scripts/__tests__/markdown_negotiation.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ test("markdown negotiation is unchanged: its .md fetch is marked, so a retired p
assert.equal(retired.probes[0]?.headers["x-markdown-negotiation"], "subrequest");
});

test("a markdown request for a path naming another host fetches nothing and gets the normal response", async (t) => {
const { serve } = site(t);
for (const path of ["//other.example/page", "/\\other.example/page"]) {
const reply = await serve(path, { headers: { accept: "text/markdown" } });
assert.deepEqual([reply.response, reply.probes], [undefined, []], path);
}
});

test("the config turns on Netlify's error bypass, so an exception falls through to the normal response", () => {
assert.deepEqual(config, { path: "/*", onError: "bypass" });
});
10 changes: 7 additions & 3 deletions docs/scripts/__tests__/migration_ranges.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import os from "node:os";
import path from "node:path";
import { type TestContext, test } from "node:test";
import { compareVersions, parseVersion, renderRange, selectRange } from "../../src/migration_ranges.mjs";
import serveRange from "../../netlify/edge-functions/migration-notes-range.mjs";
import serveRange, { config as rangeConfig } from "../../netlify/edge-functions/migration-notes-range.mjs";
import { indexMigrationNotes, splitSections } from "../index_migration_notes.mjs";

const docs = path.join(import.meta.dirname, "../..");
Expand Down Expand Up @@ -155,6 +155,10 @@ test("the edge function serves a range, refuses a bad one, and otherwise steps a
assert.equal(await serve("?from=5.2.0", null), undefined);

fetched.length = 0;
await serveRange(new Request("https://docs.example//elsewhere.example/x/migration_notes.md?from=5.2.0"));
assert.deepEqual(fetched.map((u) => new URL(u).origin), ["https://docs.example"]);
assert.equal(await serveRange(new Request("https://docs.example//elsewhere.example/x/migration_notes.md?from=5.2.0")), undefined);
assert.deepEqual(fetched, []);
});

test("the edge function config turns on Netlify's error bypass, so an exception serves the static twin", () => {
assert.deepEqual(rangeConfig, { path: "/*/migration_notes.md", onError: "bypass" });
});
12 changes: 8 additions & 4 deletions docs/scripts/__tests__/operate_sidebar.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function sidebarIds(file: string): Set<string> {
return ids;
}

/** Doc ids under `root`/docs-operate that `root`/sidebars-operate.js does not list; `_` paths are partials. */
function orphans(root: string): string[] {
const listed = sidebarIds(path.join(root, "sidebars-operate.js"));
const pagesDir = path.join(root, "docs-operate");
/** Doc ids under `root`/`docsFolder` that `root`/`sidebar` does not list; `_` paths are partials. */
function orphans(root: string, docsFolder = "docs-operate", sidebar = "sidebars-operate.js"): string[] {
const listed = sidebarIds(path.join(root, sidebar));
const pagesDir = path.join(root, docsFolder);
const pages = fs
.readdirSync(pagesDir, { recursive: true, encoding: "utf8" })
.map((rel) => rel.split(path.sep).join("/"))
Expand Down Expand Up @@ -74,6 +74,10 @@ test("every operate page is in its sidebar or listed in UNLISTED with a reason",
);
});

test("every participate page is in its sidebar", () => {
assert.deepEqual(orphans(docsDir, "docs-participate", "sidebars-participate.js"), [], "add each page to sidebars-participate.js");
});

test("ids, sidebars and partials follow Docusaurus for shapes the operate tree does not use yet", () => {
assert.equal(docId("a/page.md", "---\r\nid: renamed\r\n---\r\n"), "a/renamed");
assert.equal(docId("a/page.md", '---\nid: "renamed #1" # note\n---\n'), "a/renamed #1");
Expand Down
240 changes: 0 additions & 240 deletions docs/sidebars.js

This file was deleted.

Loading