From da29575c2b659c7db37d60abca0686f86d6a0b4a Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Sat, 4 Sep 2021 07:48:54 +0000 Subject: [PATCH] Immediately redirect to www.gitpod.io for any website slugs. fixes #5452 --- components/dashboard/src/App.tsx | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/components/dashboard/src/App.tsx b/components/dashboard/src/App.tsx index 4739bc80e82ebd..c9cacf6f26aa21 100644 --- a/components/dashboard/src/App.tsx +++ b/components/dashboard/src/App.tsx @@ -53,6 +53,15 @@ function isGitpodIo() { return window.location.hostname === 'gitpod.io' || window.location.hostname === 'gitpod-staging.com' || window.location.hostname.endsWith('gitpod-dev.com') || window.location.hostname.endsWith('gitpod-io-dev.com') } +function isWebsiteSlug(pathName: string) { + const slugs = ['chat', 'features', 'screencasts', 'blog', 'docs', 'changelog', 'pricing', 'self-hosted', 'gitpod-vs-github-codespaces', 'support', 'about', 'careers', 'contact', 'media-kit', 'imprint', 'terms', 'privacy'] + return slugs.some(slug => pathName.startsWith('/' + slug + '/')); +} + +function getURLHash() { + return window.location.hash.replace(/^[#/]+/, ''); +} + function App() { const { user, setUser } = useContext(UserContext); const { teams, setTeams } = useContext(TeamsContext); @@ -109,6 +118,12 @@ function App() { } }, []); + // redirect to website for any website slugs + if (isGitpodIo() && isWebsiteSlug(window.location.pathname)) { + window.location.host = 'www.gitpod.io'; + return
; + } + if (isGitpodIo() && window.location.pathname === '/' && window.location.hash === '' && !loading && !user) { window.location.href = `https://www.gitpod.io`; return
; @@ -237,11 +252,11 @@ function App() { return isGitpodIo() ? // delegate to our website to handle the request (window.location.host = 'www.gitpod.io') : -
-

404

-

Page not found.

-
; - }}> +
+

404

+

Page not found.

+
; + }}> @@ -267,8 +282,4 @@ function App() { ); } -function getURLHash() { - return window.location.hash.replace(/^[#/]+/, ''); -} - export default App;