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
22 changes: 22 additions & 0 deletions tests/docs-site.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ test("bridges legacy hash routes to clean URLs", async ({ page }) => {

await page.goto("/#/api-reference");
await expect(page).toHaveURL(/\/api-reference(?:\/calls)?$/);

for (const hash of [
"api-reference",
"tag/Calls",
"/tag/Calls",
"description/auth",
"/description/auth",
"models",
"/models",
]) {
await page.goto(`/#${hash}`);
await expect(page).toHaveURL(/\/api-reference(?:\/calls)?$/);
}

await page.goto("/#calls?section=idempotency");
await expect(page).toHaveURL(/\/calls#idempotency$/);

await page.goto("/");
await expect(page).toHaveURL(/\/quickstart$/);

await page.goto("/#not-a-docs-route");
await expect(page).toHaveURL(/\/#not-a-docs-route$/);
});

test("renders every migrated guide from its file route", async ({ page }) => {
Expand Down
13 changes: 8 additions & 5 deletions zudoku.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const legacyHashRedirect = `
(() => {
if (window.location.pathname !== "/") return;

const [route, query = ""] = window.location.hash.slice(1).split("?", 2);
const [rawRoute, query = ""] = window.location.hash.slice(1).split("?", 2);
const route = rawRoute.startsWith("/") || rawRoute === "" ? rawRoute : \`/\${rawRoute}\`;
const guideRoutes = new Set([
"/quickstart",
"/authentication",
Expand All @@ -31,15 +32,17 @@ const legacyHashRedirect = `
if (
route === "/api-reference" ||
route.startsWith("/api-1/") ||
route.startsWith("tag/") ||
route.startsWith("description/") ||
route === "models"
route.startsWith("/tag/") ||
route.startsWith("/description/") ||
route === "/models"
) {
window.location.replace("/api-reference");
return;
}

window.location.replace("/quickstart");
if (rawRoute === "") {
window.location.replace("/quickstart");
}
})();
`;

Expand Down