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
93 changes: 52 additions & 41 deletions apps/website/src/config/redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { z } from 'zod'
import { websiteRoot } from '@website/paths'
import { modelsBuildRoutes } from '@/integrations/workshop-release-gate'
import { routeOf } from '@/utils/hreflangRoutes'
import { hubAppSlugs, hubModelAliases, hubModelSlugs } from './hub-models'
import { modelPageUrls } from './model-urls'
import hubAppNames from './hub-app-names.json' with { type: 'json' }
import hubWorkflowNames from './hub-workflow-names.json' with { type: 'json' }
import { hubModelAliases } from './hub-models'
import { modelAliasUrls, modelPageUrls } from './model-urls'
import { models } from './models'
import { modelsUrlKind } from './models-url-registry'
import {
Expand Down Expand Up @@ -142,21 +144,7 @@ describe('generated Vercel rules', () => {
{
source: '/p/supported-models/t5xxl-fp8-e4m3fn-scaled',
destination: '/p/supported-models/t5xxl-fp16/'
}
])(
'send $source and $source/ to $destination permanently',
({ source, destination }) => {
for (const form of [source, `${source}/`]) {
expect(find(form)).toEqual({
source: form,
destination,
permanent: true
})
}
}
)

it.for([
},
{ source: '/models', destination: '/hub/models/' },
{
source: '/models/workflows/change-material',
Expand All @@ -175,25 +163,22 @@ describe('generated Vercel rules', () => {
destination: `/hub/models/${hubModelAliases.get('vertexai--gemini-3-pro-image')}/`
}
])(
'send $source and $source/ to $destination temporarily until comfy-router#46 is live',
'send $source and $source/ to $destination permanently',
({ source, destination }) => {
for (const form of [source, `${source}/`]) {
expect(find(form)).toEqual({
source: form,
destination,
permanent: false
permanent: true
})
}
}
)

it('keeps only the listed rows and the old Models addresses temporary', () => {
it('keeps only the listed rows temporary', () => {
expect(
vercelRedirects
.filter(
({ source, permanent }) =>
!permanent && source !== '/models' && !source.startsWith('/models/')
)
.filter(({ permanent }) => !permanent)
.map(({ source }) => source)
).toEqual([
'/trust',
Expand Down Expand Up @@ -262,26 +247,52 @@ describe('Astro redirects', () => {

describe('old Models addresses', () => {
const vercelRedirects = toVercelRedirects(siteRedirects)
const oldPaths = [
'/models',
...[...hubModelSlugs.keys(), ...hubModelAliases.keys(), ...hubAppSlugs].map(
(slug) => `/models/${slug}`
const frozenDestinations: [string, string][] = [
['/models', '/hub/models/'],
...modelPageUrls.map(({ oldSlug, newSlug }): [string, string] => [
`/models/${oldSlug}`,
`/hub/models/${newSlug}/`
]),
...modelAliasUrls.map(({ alias, newSlug }): [string, string] => [
`/models/${alias}`,
`/hub/models/${newSlug}/`
]),
...hubWorkflowNames.map((name): [string, string] => [
`/models/workflows/${name}`,
`/hub/workflows/${name}/`
]),
...hubAppNames.map((name): [string, string] => [
`/models/apps/${name}`,
`/hub/apps/${name}/`
])
].flatMap(([path, destination]) => [
[path, destination],
[`${path}/`, destination]
])

it('each redirect once, permanently, to the page in the frozen URL tables', () => {
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
const served = (path: string) =>
vercelRedirects
.filter(({ source }) => source === path)
.map(({ permanent, destination }) =>
permanent ? destination : `temporary ${destination}`
)
expect(
Object.fromEntries(
frozenDestinations.map(([path]) => [path, served(path)])
)
).toEqual(
Object.fromEntries(
frozenDestinations.map(([path, destination]) => [path, [destination]])
)
)
].flatMap((path) => [path, `${path}/`])
})

it('each redirect once, temporarily, to a page the site builds', () => {
const landsOnPage = (destination: string) =>
['model', 'hub', 'app'].includes(modelsUrlKind(destination) ?? '')
it('each is an alias in the Models URL registry', () => {
expect(
oldPaths.filter((path) => {
const rows = vercelRedirects.filter(({ source }) => source === path)
return (
modelsUrlKind(path) !== 'alias' ||
rows.length !== 1 ||
rows[0].permanent ||
!landsOnPage(rows[0].destination)
)
})
frozenDestinations
.map(([path]) => path)
.filter((path) => modelsUrlKind(path) !== 'alias')
).toEqual([])
})
})
Expand Down
23 changes: 6 additions & 17 deletions apps/website/src/config/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,22 @@ const modelAliasRedirects = models.flatMap(({ slug, canonicalSlug }) =>
: []
)

const HUB_ROUTER_PENDING =
'switch to permanent once comfy-router#46 is confirmed live on prod; a 308 is cached by browsers and cannot be retracted'

const HUB_APPS_ROUTER_PENDING =
'switch to permanent once comfy-router sends /hub/apps/ to this site on prod; a 308 is cached by browsers and cannot be retracted'

// Permanent since comfy-router#46: prod serves /hub/models, /hub/workflows and /hub/apps from this site.
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
// 308 tells search engines the move is permanent: confirm a new destination serves 200 first.
// Literal rows only: hub pages fetch /models/<slug>/page.json, so a /models/:path* catch-all would break them.
const hubModelRedirects: readonly SiteRedirect[] = [
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
{
source: '/models',
destination: `${HUB_MODELS_PATH}/`,
temporaryBecause: HUB_ROUTER_PENDING
},
{ source: '/models', destination: `${HUB_MODELS_PATH}/` },
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
...[...hubModelSlugs, ...hubModelAliases].map(([slug, hubSlug]) => ({
source: `/models/${slug}` as const,
destination: hubModelPath(hubSlug),
temporaryBecause: HUB_ROUTER_PENDING
destination: hubModelPath(hubSlug)
})),
...hubWorkflowSlugs.map((slug) => ({
source: `/models/${slug}` as const,
destination: hubWorkflowHref(slug),
temporaryBecause: HUB_ROUTER_PENDING
destination: hubWorkflowHref(slug)
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
})),
...hubAppSlugs.map((slug) => ({
source: `/models/${slug}` as const,
destination: hubAppHref(slug),
temporaryBecause: HUB_APPS_ROUTER_PENDING
destination: hubAppHref(slug)
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
Comment thread
MaanilVerma marked this conversation as resolved.
Resolved
}))
]

Expand Down
Loading
Loading