-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathResolveRoute.js
More file actions
74 lines (72 loc) · 2.15 KB
/
ResolveRoute.js
File metadata and controls
74 lines (72 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* eslint-disable no-useless-escape */
import GDPRUserList from './utils/GDPRUserList';
export const routeRegex = {
UserProfile1: /^\/(@[\w\.\d-]+)\/?$/,
UserProfile2: /^\/(@[\w\.\d-]+)\/(transfers|curation-rewards|author-rewards|permissions|communities|password|settings|delegations|proposals|witnesses)\/?$/,
};
export default function resolveRoute(path) {
if (path === '/') {
return { page: 'WalletIndex' };
}
if (path === '/about.html') {
return { page: 'About' };
}
if (path === '/welcome') {
return { page: 'Welcome' };
}
if (path === '/faq.html') {
return { page: 'Faq' };
}
if (path === '/login.html') {
return { page: 'Login' };
}
if (path === '/privacy.html') {
return { page: 'Privacy' };
}
if (path === '/support.html') {
return { page: 'Support' };
}
if (path === '/xss/test' && process.env.NODE_ENV === 'development') {
return { page: 'XSSTest' };
}
if (path === '/benchmark' && process.env.OFFLINE_SSR_TEST) {
return { page: 'Benchmark' };
}
if (path === '/tos.html') {
return { page: 'Tos' };
}
if (path === '/change_password') {
return { page: 'ChangePassword' };
}
if (path === '/create_account') {
return { page: 'CreateAccount' };
}
if (path === '/approval') {
return { page: 'Approval' };
}
if (path === '/recover_account_step_1') {
return { page: 'RecoverAccountStep1' };
}
if (path === '/recover_account_step_2') {
return { page: 'RecoverAccountStep2' };
}
if (path === '/market') {
return { page: 'Market' };
}
if (path === '/~witnesses') {
return { page: 'Witnesses' };
}
if (path === '/proposals') {
return { page: 'Proposals' };
}
const match =
path.match(routeRegex.UserProfile1) ||
path.match(routeRegex.UserProfile2);
if (match) {
if (GDPRUserList.includes(match[1].substring(1))) {
return { page: 'NotFound' };
}
return { page: 'UserProfile', params: match.slice(1) };
}
return { page: 'NotFound' };
}