diff --git a/src/lib/vercel-routing.test.ts b/src/lib/vercel-routing.test.ts new file mode 100644 index 00000000..4a04714e --- /dev/null +++ b/src/lib/vercel-routing.test.ts @@ -0,0 +1,32 @@ +import fs from 'node:fs' +import { describe, expect, it } from 'vitest' + +type VercelConfig = { + rewrites?: Array<{ source: string; destination: string }> +} + +describe('Vercel routing', () => { + it('normalizes doubled /developers RSC routes at the edge', () => { + const config = JSON.parse(fs.readFileSync('vercel.json', 'utf8')) as VercelConfig + const rewrites = config.rewrites ?? [] + + expect(rewrites.slice(0, 4)).toEqual([ + { + source: '/developers/RSC/R/developers.txt', + destination: '/developers/RSC/R/_root.txt', + }, + { + source: '/developers/RSC/R/developers/:path(.*)', + destination: '/developers/RSC/R/:path', + }, + { + source: '/RSC/R/developers.txt', + destination: '/RSC/R/_root.txt', + }, + { + source: '/RSC/R/developers/:path(.*)', + destination: '/RSC/R/:path', + }, + ]) + }) +}) diff --git a/vercel.json b/vercel.json index 39ef50da..8080728b 100644 --- a/vercel.json +++ b/vercel.json @@ -206,6 +206,22 @@ } ], "rewrites": [ + { + "source": "/developers/RSC/R/developers.txt", + "destination": "/developers/RSC/R/_root.txt" + }, + { + "source": "/developers/RSC/R/developers/:path(.*)", + "destination": "/developers/RSC/R/:path" + }, + { + "source": "/RSC/R/developers.txt", + "destination": "/RSC/R/_root.txt" + }, + { + "source": "/RSC/R/developers/:path(.*)", + "destination": "/RSC/R/:path" + }, { "source": "/ingest/static/:path(.*)", "destination": "https://us-assets.i.posthog.com/static/:path"