|
1 | 1 | import '../css/404.css'; |
2 | 2 | import '../css/status.css'; |
3 | | -import { detectTopicFromUrl } from './shared/common'; |
| 3 | +import { handleAppNavigator404 } from './app-navigator/404'; |
| 4 | +import { handleChangelog404 } from './changelog/404'; |
| 5 | +import { handleIntegrations404 } from './integrations/404'; |
| 6 | +import { handleStacks404 } from './stacks/404'; |
4 | 7 | import { renderStatus } from './shared/status'; |
5 | 8 |
|
6 | 9 | (async () => { |
7 | 10 | const url = new URL(document.location.href); |
8 | | - const topicSlugId = detectTopicFromUrl(url, 'changelog', 'topic'); |
9 | | - if (topicSlugId) { |
10 | | - const changelogProxyAvailable = await fetch('/changelog-proxy') |
11 | | - .then((changelogProxyResponse) => changelogProxyResponse.ok) |
12 | | - .catch(() => false); |
13 | | - if (!changelogProxyAvailable) { |
14 | | - window.location.href = `/changelog/topic?topic=${topicSlugId}`; |
15 | | - } |
16 | | - } |
17 | | - |
18 | | - const subpagePath = detectTopicFromUrl(url, 'stacks', 'subpage'); |
19 | | - if (subpagePath) { |
20 | | - const stacksProxyAvailable = await fetch('/stacks-proxy') |
21 | | - .then((stacksProxyResponse) => stacksProxyResponse.ok) |
22 | | - .catch(() => false); |
23 | | - if (!stacksProxyAvailable) { |
24 | | - window.location.href = `/stacks/subpage?subpage=${subpagePath}`; |
25 | | - } |
26 | | - } |
27 | | - |
28 | | - const stepPath = detectTopicFromUrl(url, 'integrations/steps', 'step'); |
29 | | - if (stepPath) { |
30 | | - const integrationsProxyAvailable = await fetch('/integrations-proxy') |
31 | | - .then((integrationsProxyResponse) => integrationsProxyResponse.ok) |
32 | | - .catch(() => false); |
33 | | - if (!integrationsProxyAvailable) { |
34 | | - window.location.href = `/integrations/step?step=${stepPath}`; |
35 | | - } |
36 | | - } |
37 | | - |
38 | | - if (url.pathname.match(/^\/resources\/tools\/app-navigator/)) { |
39 | | - const appNavigatorProxyAvailable = await fetch('/resources/tools/app-navigator-proxy') |
40 | | - .then((appNavigatorProxyResponse) => appNavigatorProxyResponse.ok) |
41 | | - .catch(() => false); |
42 | | - if (!appNavigatorProxyAvailable) { |
43 | | - window.location.href = `https://app.bitrise.io${url.pathname}`; |
44 | | - } |
45 | | - } |
| 11 | + await handleStacks404(url); |
| 12 | + await handleChangelog404(url); |
| 13 | + await handleIntegrations404(url); |
| 14 | + await handleAppNavigator404(url); |
46 | 15 | })(); |
47 | 16 |
|
48 | 17 | window.addEventListener('load', async () => { |
|
0 commit comments