Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
12088540
Unverified
Commit
12088540
authored
Oct 15, 2022
by
Igor Stuev
Committed by
GitHub
Oct 15, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #239 from blockscout/redirects
Redirects
parents
fab13d4a
bff2dbbb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
25 deletions
+106
-25
redirects.js
configs/nextjs/redirects.js
+52
-0
basePath.js
lib/link/basePath.js
+3
-0
paths.js
lib/link/paths.js
+27
-0
routes.ts
lib/link/routes.ts
+24
-25
No files found.
configs/nextjs/redirects.js
View file @
12088540
const
BASE_PATH
=
require
(
'
../../lib/link/basePath.js
'
);
const
PATHS
=
require
(
'
../../lib/link/paths.js
'
);
const
oldUrls
=
[
{
oldPath
:
'
/account/tag_address
'
,
newPath
:
`
${
PATHS
.
private_tags
}
?tab=address`
,
},
{
oldPath
:
'
/account/tag_transaction
'
,
newPath
:
`
${
PATHS
.
private_tags
}
?tab=tx`
,
},
{
oldPath
:
'
/pending-transactions
'
,
newPath
:
`
${
PATHS
.
txs
}
?tab=pending`
,
},
{
oldPath
:
'
/tx/:id/internal-transactions
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=internal`
,
},
{
oldPath
:
'
/tx/:id/logs
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=logs`
,
},
{
oldPath
:
'
/tx/:id/raw-trace
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=raw_trace`
,
},
{
oldPath
:
'
/tx/:id/state
'
,
newPath
:
`
${
PATHS
.
tx
}
?tab=state`
,
},
{
oldPath
:
'
/uncles
'
,
newPath
:
`
${
PATHS
.
blocks
}
?tab=uncles`
,
},
{
oldPath
:
'
/reorgs
'
,
newPath
:
`
${
PATHS
.
blocks
}
?tab=reorgs`
,
},
{
oldPath
:
'
/block/:id/transactions
'
,
newPath
:
`
${
PATHS
.
block
}
?tab=txs`
,
},
];
async
function
redirects
()
{
async
function
redirects
()
{
const
homePagePath
=
'
/
'
+
[
process
.
env
.
NEXT_PUBLIC_NETWORK_TYPE
,
process
.
env
.
NEXT_PUBLIC_NETWORK_SUBTYPE
].
filter
(
Boolean
).
join
(
'
/
'
);
const
homePagePath
=
'
/
'
+
[
process
.
env
.
NEXT_PUBLIC_NETWORK_TYPE
,
process
.
env
.
NEXT_PUBLIC_NETWORK_SUBTYPE
].
filter
(
Boolean
).
join
(
'
/
'
);
return
[
return
[
{
{
source
:
'
/
'
,
source
:
'
/
'
,
destination
:
homePagePath
,
destination
:
homePagePath
,
permanent
:
false
,
permanent
:
false
,
},
},
...
oldUrls
.
map
(
item
=>
{
const
source
=
BASE_PATH
.
replaceAll
(
'
[
'
,
'
:
'
).
replaceAll
(
'
]
'
,
''
)
+
item
.
oldPath
;
const
destination
=
item
.
newPath
.
replaceAll
(
'
[
'
,
'
:
'
).
replaceAll
(
'
]
'
,
''
);
return
{
source
,
destination
,
permanent
:
false
};
}),
];
];
}
}
...
...
lib/link/basePath.js
0 → 100644
View file @
12088540
const
BASE_PATH
=
'
/[network_type]/[network_sub_type]
'
;
module
.
exports
=
BASE_PATH
;
lib/link/paths.js
0 → 100644
View file @
12088540
const
BASE_PATH
=
require
(
'
./basePath
'
);
const
paths
=
{
network_index
:
`
${
BASE_PATH
}
`
,
watchlist
:
`
${
BASE_PATH
}
/account/watchlist`
,
private_tags
:
`
${
BASE_PATH
}
/account/tag_address`
,
public_tags
:
`
${
BASE_PATH
}
/account/public_tags_request`
,
api_keys
:
`
${
BASE_PATH
}
/account/api_key`
,
custom_abi
:
`
${
BASE_PATH
}
/account/custom_abi`
,
profile
:
`
${
BASE_PATH
}
/auth/profile`
,
txs
:
`
${
BASE_PATH
}
/txs`
,
tx
:
`
${
BASE_PATH
}
/tx/[id]`
,
blocks
:
`
${
BASE_PATH
}
/blocks`
,
block
:
`
${
BASE_PATH
}
/block/[id]`
,
tokens
:
`
${
BASE_PATH
}
/tokens`
,
token_index
:
`
${
BASE_PATH
}
/token/[id]`
,
address_index
:
`
${
BASE_PATH
}
/address/[id]`
,
address_contract_verification
:
`
${
BASE_PATH
}
/address/[id]/contract_verifications/new`
,
apps
:
`
${
BASE_PATH
}
/apps`
,
app_index
:
`
${
BASE_PATH
}
/apps/[id]`
,
search_results
:
`
${
BASE_PATH
}
/search-results`
,
other
:
`
${
BASE_PATH
}
/search-results`
,
// no slash required, it is correct
auth
:
`
${
BASE_PATH
}
auth/auth0`
,
};
module
.
exports
=
paths
;
lib/link/routes.ts
View file @
12088540
import
appConfig
from
'
configs/app/config
'
;
import
PATHS
from
'
./paths.js
'
;
export
interface
Route
{
export
interface
Route
{
pattern
:
string
;
pattern
:
string
;
crossNetworkNavigation
?:
boolean
;
// route will not change when switching networks
crossNetworkNavigation
?:
boolean
;
// route will not change when switching networks
}
}
import
appConfig
from
'
configs/app/config
'
;
export
type
RouteName
=
keyof
typeof
ROUTES
;
export
type
RouteName
=
keyof
typeof
ROUTES
;
const
BASE_PATH
=
'
/[network_type]/[network_sub_type]
'
;
export
const
ROUTES
=
{
export
const
ROUTES
=
{
// NETWORK MAIN PAGE
// NETWORK MAIN PAGE
network_index
:
{
network_index
:
{
pattern
:
`
${
BASE_PATH
}
`
,
pattern
:
PATHS
.
network_index
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
// ACCOUNT
// ACCOUNT
watchlist
:
{
watchlist
:
{
pattern
:
`
${
BASE_PATH
}
/account/watchlist`
,
pattern
:
PATHS
.
watchlist
,
},
},
private_tags
:
{
private_tags
:
{
pattern
:
`
${
BASE_PATH
}
/account/tag_address`
,
pattern
:
PATHS
.
private_tags
,
},
},
public_tags
:
{
public_tags
:
{
pattern
:
`
${
BASE_PATH
}
/account/public_tags_request`
,
pattern
:
PATHS
.
public_tags
,
},
},
api_keys
:
{
api_keys
:
{
pattern
:
`
${
BASE_PATH
}
/account/api_key`
,
pattern
:
PATHS
.
api_keys
,
},
},
custom_abi
:
{
custom_abi
:
{
pattern
:
`
${
BASE_PATH
}
/account/custom_abi`
,
pattern
:
PATHS
.
custom_abi
,
},
},
profile
:
{
profile
:
{
pattern
:
`
${
BASE_PATH
}
/auth/profile`
,
pattern
:
PATHS
.
profile
,
},
},
// TRANSACTIONS
// TRANSACTIONS
txs
:
{
txs
:
{
pattern
:
`
${
BASE_PATH
}
/txs`
,
pattern
:
PATHS
.
txs
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
tx
:
{
tx
:
{
pattern
:
`
${
BASE_PATH
}
/tx/[id]`
,
pattern
:
PATHS
.
tx
,
},
},
// BLOCKS
// BLOCKS
blocks
:
{
blocks
:
{
pattern
:
`
${
BASE_PATH
}
/blocks`
,
pattern
:
PATHS
.
blocks
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
block
:
{
block
:
{
pattern
:
`
${
BASE_PATH
}
/block/[id]`
,
pattern
:
PATHS
.
block
,
},
},
// TOKENS
// TOKENS
tokens
:
{
tokens
:
{
pattern
:
`
${
BASE_PATH
}
/tokens`
,
pattern
:
PATHS
.
tokens
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
token_index
:
{
token_index
:
{
pattern
:
`
${
BASE_PATH
}
/token/[id]`
,
pattern
:
PATHS
.
token_index
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
// ADDRESSES
// ADDRESSES
address_index
:
{
address_index
:
{
pattern
:
`
${
BASE_PATH
}
/address/[id]`
,
pattern
:
PATHS
.
address_index
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
address_contract_verification
:
{
address_contract_verification
:
{
pattern
:
`
${
BASE_PATH
}
/address/[id]/contract_verifications/new`
,
pattern
:
PATHS
.
address_contract_verification
,
crossNetworkNavigation
:
true
,
crossNetworkNavigation
:
true
,
},
},
// APPS
// APPS
apps
:
{
apps
:
{
pattern
:
`
${
BASE_PATH
}
/apps`
,
pattern
:
PATHS
.
apps
,
},
},
app_index
:
{
app_index
:
{
pattern
:
`
${
BASE_PATH
}
/apps/[id]`
,
pattern
:
PATHS
.
app_index
,
},
},
// SEARCH
// SEARCH
search_results
:
{
search_results
:
{
pattern
:
`
${
BASE_PATH
}
/apps`
,
pattern
:
PATHS
.
search_results
,
},
},
// ??? what URL will be here
// ??? what URL will be here
other
:
{
other
:
{
pattern
:
`
${
BASE_PATH
}
/search-results`
,
pattern
:
PATHS
.
other
,
},
},
// AUTH
// AUTH
auth
:
{
auth
:
{
// no slash required, it is correct
pattern
:
PATHS
.
auth
,
pattern
:
`
${
BASE_PATH
}
auth/auth0`
,
},
},
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment