@@ -14,12 +14,43 @@ const vercelConfig = JSON.parse(
1414) as { redirects : Redirect [ ] }
1515
1616const redirects = vercelConfig . redirects . filter ( ( redirect ) => ! redirect . has )
17+ const hostRedirects = vercelConfig . redirects . filter ( ( redirect ) => redirect . has )
1718
1819function findRedirect ( source : string ) {
1920 return redirects . find ( ( redirect ) => redirect . source === source )
2021}
2122
23+ function findHostRedirect ( source : string , host : string ) {
24+ return hostRedirects . find (
25+ ( redirect ) =>
26+ redirect . source === source &&
27+ Array . isArray ( redirect . has ) &&
28+ redirect . has . some (
29+ ( condition ) =>
30+ typeof condition === 'object' &&
31+ condition !== null &&
32+ 'type' in condition &&
33+ 'value' in condition &&
34+ condition . type === 'host' &&
35+ condition . value === host ,
36+ ) ,
37+ )
38+ }
39+
2240describe ( 'docs routing redirects' , ( ) => {
41+ it . each ( [
42+ [ '/' , 'https://tempo.xyz/developers' ] ,
43+ [ '/developers' , 'https://tempo.xyz/developers' ] ,
44+ [ '/developers/:path*' , 'https://tempo.xyz/developers/:path*' ] ,
45+ [ '/:path*' , 'https://tempo.xyz/developers/:path*' ] ,
46+ ] ) ( 'redirects docs.tempo.xyz%s to %s' , ( source , destination ) => {
47+ expect ( findHostRedirect ( source , 'docs.tempo.xyz' ) ) . toMatchObject ( {
48+ source,
49+ destination,
50+ permanent : true ,
51+ } )
52+ } )
53+
2354 it . each ( [
2455 [ '/tools' , '/docs/tools' ] ,
2556 [ '/tools/:path*' , '/docs/tools/:path*' ] ,
0 commit comments