Skip to content

Commit bcbbcbb

Browse files
authored
Redirect docs domain to developers (#607)
1 parent ab8c32e commit bcbbcbb

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

src/lib/docs-routing.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,43 @@ const vercelConfig = JSON.parse(
1414
) as { redirects: Redirect[] }
1515

1616
const redirects = vercelConfig.redirects.filter((redirect) => !redirect.has)
17+
const hostRedirects = vercelConfig.redirects.filter((redirect) => redirect.has)
1718

1819
function 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+
2240
describe('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*'],

vercel.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
{
22
"redirects": [
3+
{
4+
"source": "/",
5+
"has": [
6+
{
7+
"type": "host",
8+
"value": "docs.tempo.xyz"
9+
}
10+
],
11+
"destination": "https://tempo.xyz/developers",
12+
"permanent": true
13+
},
14+
{
15+
"source": "/developers",
16+
"has": [
17+
{
18+
"type": "host",
19+
"value": "docs.tempo.xyz"
20+
}
21+
],
22+
"destination": "https://tempo.xyz/developers",
23+
"permanent": true
24+
},
25+
{
26+
"source": "/developers/:path*",
27+
"has": [
28+
{
29+
"type": "host",
30+
"value": "docs.tempo.xyz"
31+
}
32+
],
33+
"destination": "https://tempo.xyz/developers/:path*",
34+
"permanent": true
35+
},
36+
{
37+
"source": "/:path*",
38+
"has": [
39+
{
40+
"type": "host",
41+
"value": "docs.tempo.xyz"
42+
}
43+
],
44+
"destination": "https://tempo.xyz/developers/:path*",
45+
"permanent": true
46+
},
347
{
448
"source": "/",
549
"has": [

0 commit comments

Comments
 (0)