diff --git a/src/lib/docs-routing.test.ts b/src/lib/docs-routing.test.ts index 53b2ea6a..768a8007 100644 --- a/src/lib/docs-routing.test.ts +++ b/src/lib/docs-routing.test.ts @@ -14,12 +14,40 @@ const vercelConfig = JSON.parse( ) as { redirects: Redirect[] } const redirects = vercelConfig.redirects.filter((redirect) => !redirect.has) +const hostRedirects = vercelConfig.redirects.filter((redirect) => + Array.isArray(redirect.has) + ? redirect.has.some( + (condition) => + typeof condition === 'object' && + condition !== null && + 'type' in condition && + 'value' in condition && + condition.type === 'host' && + condition.value === 'docs.tempo.xyz', + ) + : false, +) function findRedirect(source: string) { return redirects.find((redirect) => redirect.source === source) } describe('docs routing redirects', () => { + it.each([ + ['/', 'https://tempo.xyz/developers'], + ['/developers', 'https://tempo.xyz/developers'], + ['/developers/:path*', 'https://tempo.xyz/developers/:path*'], + ['/:path*', 'https://tempo.xyz/developers/:path*'], + ])('redirects docs.tempo.xyz%s to %s', (source, destination) => { + expect(hostRedirects).toContainEqual( + expect.objectContaining({ + source, + destination, + permanent: true, + }), + ) + }) + it.each([ ['/tools', '/docs/tools'], ['/tools/:path*', '/docs/tools/:path*'], diff --git a/vercel.json b/vercel.json index 71ba6ddc..8b39c807 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,49 @@ { "redirects": [ + { + "source": "/", + "has": [ + { + "type": "host", + "value": "docs.tempo.xyz" + } + ], + "destination": "https://tempo.xyz/developers", + "permanent": true + }, + { + "source": "/developers", + "has": [ + { + "type": "host", + "value": "docs.tempo.xyz" + } + ], + "destination": "https://tempo.xyz/developers", + "permanent": true + }, + { + "source": "/developers/:path*", + "has": [ + { + "type": "host", + "value": "docs.tempo.xyz" + } + ], + "destination": "https://tempo.xyz/developers/:path*", + "permanent": true + }, + { + "source": "/:path*", + "has": [ + { + "type": "host", + "value": "docs.tempo.xyz" + } + ], + "destination": "https://tempo.xyz/developers/:path*", + "permanent": true + }, { "source": "/", "has": [