formacao
This commit is contained in:
+2
-2
@@ -19,14 +19,14 @@ var trimTrailingSlash = (options) => {
|
||||
var appendTrailingSlash = (options) => {
|
||||
return async function appendTrailingSlash2(c, next) {
|
||||
if (options?.alwaysRedirect) {
|
||||
if ((c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/") {
|
||||
if ((c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/" && !options.skip?.(c.req.path)) {
|
||||
const url = new URL(c.req.url);
|
||||
url.pathname += "/";
|
||||
return c.redirect(url.toString(), 301);
|
||||
}
|
||||
}
|
||||
await next();
|
||||
if (!options?.alwaysRedirect && c.res.status === 404 && (c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/") {
|
||||
if (!options?.alwaysRedirect && c.res.status === 404 && (c.req.method === "GET" || c.req.method === "HEAD") && c.req.path.at(-1) !== "/" && !options?.skip?.(c.req.path)) {
|
||||
const url = new URL(c.req.url);
|
||||
url.pathname += "/";
|
||||
c.res = c.redirect(url.toString(), 301);
|
||||
|
||||
Reference in New Issue
Block a user