Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit e4e1f55

Browse files
authored
fix(svelte): Properly redirect to cody marketing page (#64331)
Fixes srch-851 A consequence of https://github.com/sourcegraph/sourcegraph/pull/64272 is that redirecting to the cody marketing page on dotcom didn't work. That's because `/cody` is not provided by the server as a known page. A simple fix would be to mark the link as external, but we'd have to keep in mind to do this in all places (present and future). A more "central" fix is to add this page to a hardcoded list of known pages that are not provided by the server. ## Test plan Manual testing
1 parent 2e0a3ee commit e4e1f55

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

client/web-sveltekit/src/lib/navigation.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import { svelteKitRoutes, type SvelteKitRoute } from './routes'
44

55
let knownRoutesRegex: RegExp | undefined
66

7+
// Additional known routes that are not in the list of known routes provided by the server.
8+
// Having a separate list is error-prone and should be avoided if possible.
9+
const additionalKnownRoutes: string[] = [
10+
// Cody's marketing page
11+
'^/cody/?$',
12+
]
13+
714
function getKnownRoutesRegex(): RegExp {
815
if (!knownRoutesRegex) {
9-
const knownRoutes = (browser && window.context?.svelteKit?.knownRoutes) || []
10-
knownRoutesRegex =
11-
knownRoutes.length === 0 ? /$^/ : new RegExp(`(${window.context?.svelteKit?.knownRoutes?.join(')|(')})`)
16+
const knownRoutes = additionalKnownRoutes.concat((browser && window.context?.svelteKit?.knownRoutes) || [])
17+
knownRoutesRegex = knownRoutes.length === 0 ? /$^/ : new RegExp(`${knownRoutes.join('|')}`)
1218
}
1319
return knownRoutesRegex
1420
}

0 commit comments

Comments
 (0)