Skip to content

Commit

Permalink
Immediately redirect to www.gitpod.io for any website slugs.
Browse files Browse the repository at this point in the history
fixes #5452
  • Loading branch information
svenefftinge committed Sep 4, 2021
1 parent 71cb39f commit da29575
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions components/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 <div></div>;
}

if (isGitpodIo() && window.location.pathname === '/' && window.location.hash === '' && !loading && !user) {
window.location.href = `https://www.gitpod.io`;
return <div></div>;
Expand Down Expand Up @@ -237,11 +252,11 @@ function App() {
return isGitpodIo() ?
// delegate to our website to handle the request
(window.location.host = 'www.gitpod.io') :
<div className="mt-48 text-center">
<h1 className="text-gray-500 text-3xl">404</h1>
<p className="mt-4 text-lg">Page not found.</p>
</div>;
}}>
<div className="mt-48 text-center">
<h1 className="text-gray-500 text-3xl">404</h1>
<p className="mt-4 text-lg">Page not found.</p>
</div>;
}}>
</Route>
</Switch>
</div>
Expand All @@ -267,8 +282,4 @@ function App() {
);
}

function getURLHash() {
return window.location.hash.replace(/^[#/]+/, '');
}

export default App;

0 comments on commit da29575

Please sign in to comment.