From c9d944c5eb95df5dba6e867890f91ba0b3cc5485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mime=20=C4=8Cuvalo?= Date: Mon, 22 Apr 2024 11:54:26 +0100 Subject: [PATCH] create redirects --- apps/dotcom/src/__snapshots__/routes.test.tsx.snap | 4 ++++ apps/dotcom/src/routes.test.tsx | 1 + apps/dotcom/src/routes.tsx | 12 +++--------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/dotcom/src/__snapshots__/routes.test.tsx.snap b/apps/dotcom/src/__snapshots__/routes.test.tsx.snap index 48a05ab57..4d6d55f9b 100644 --- a/apps/dotcom/src/__snapshots__/routes.test.tsx.snap +++ b/apps/dotcom/src/__snapshots__/routes.test.tsx.snap @@ -6,6 +6,10 @@ exports[`the_routes 1`] = ` "reactRouterPattern": "/", "vercelRouterPattern": "^//?$", }, + { + "reactRouterPattern": "/new", + "vercelRouterPattern": "^/new/?$", + }, { "reactRouterPattern": "/r", "vercelRouterPattern": "^/r/?$", diff --git a/apps/dotcom/src/routes.test.tsx b/apps/dotcom/src/routes.test.tsx index b3bc91671..a68dafb3a 100644 --- a/apps/dotcom/src/routes.test.tsx +++ b/apps/dotcom/src/routes.test.tsx @@ -111,6 +111,7 @@ test('all React routes match', () => { test("non-react routes don't match", () => { // lil smoke test for basic patterns expect('/').toMatchAny(allvercelRouterPatterns) + expect('/new').toMatchAny(allvercelRouterPatterns) expect('/r/whatever').toMatchAny(allvercelRouterPatterns) expect('/r/whatever/').toMatchAny(allvercelRouterPatterns) diff --git a/apps/dotcom/src/routes.tsx b/apps/dotcom/src/routes.tsx index fa4022c42..dc2ad3093 100644 --- a/apps/dotcom/src/routes.tsx +++ b/apps/dotcom/src/routes.tsx @@ -1,7 +1,6 @@ import { captureException } from '@sentry/react' -import { nanoid } from 'nanoid' import { useEffect } from 'react' -import { createRoutesFromElements, Outlet, redirect, Route, useRouteError } from 'react-router-dom' +import { createRoutesFromElements, Navigate, Outlet, Route, useRouteError } from 'react-router-dom' import { DefaultErrorFallback } from './components/DefaultErrorFallback/DefaultErrorFallback' import { ErrorPage } from './components/ErrorPage/ErrorPage' @@ -30,13 +29,8 @@ export const router = createRoutesFromElements( > }> import('./pages/root')} /> - { - const id = 'v2' + nanoid() - return redirect(`/r/${id}`) - }} - /> + } /> + } /> import('./pages/public-multiplayer')} /> import('./pages/history')} />