Revert "remove unnecessary redirect in server"
This reverts commit e21b5be6f6
.
This commit is contained in:
parent
75b1bf3a77
commit
63d8f1731e
1 changed files with 5 additions and 1 deletions
|
@ -5,7 +5,6 @@ async function redirectMiddleware(ctx, next) {
|
|||
const requestHost = ctx.host;
|
||||
const path = ctx.path;
|
||||
const url = ctx.url;
|
||||
|
||||
// Getting err: too many redirects on some urls because of this
|
||||
// Need a better solution
|
||||
// const decodedUrl = decodeURIComponent(url);
|
||||
|
@ -15,6 +14,11 @@ async function redirectMiddleware(ctx, next) {
|
|||
// return;
|
||||
// }
|
||||
|
||||
if (path.endsWith('/') && path.length > 1) {
|
||||
ctx.redirect(url.replace(/\/$/, ''));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!path.startsWith('/$/') && path.match(/^([^@/:]+)\/([^:/]+)$/)) {
|
||||
ctx.redirect(url.replace(/^([^@/:]+)\/([^:/]+)(:(\/.*))/, '$1:$2')); // test against path, but use ctx.url to retain parameters
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue