formacao
This commit is contained in:
+2
-3
@@ -1,4 +1,3 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
@@ -42,14 +41,14 @@ const trimTrailingSlash = (options) => {
|
||||
const 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