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