@@ -13,7 +13,7 @@ type TrimTrailingSlashOptions = {
1313 * If `false` (default), it will only redirect when the route is not found (404).
1414 * @default false
1515 */
16- eager ?: boolean
16+ alwaysRedirect ?: boolean
1717}
1818
1919/**
@@ -34,16 +34,16 @@ type TrimTrailingSlashOptions = {
3434 *
3535 * @example
3636 * ```ts
37- * // With eager option for wildcard routes
37+ * // With alwaysRedirect option for wildcard routes
3838 * const app = new Hono()
3939 *
40- * app.use(trimTrailingSlash({ eager : true }))
40+ * app.use(trimTrailingSlash({ alwaysRedirect : true }))
4141 * app.get('/my-path/*', (c) => c.text('Wildcard route'))
4242 * ```
4343 */
4444export const trimTrailingSlash = ( options ?: TrimTrailingSlashOptions ) : MiddlewareHandler => {
4545 return async function trimTrailingSlash ( c , next ) {
46- if ( options ?. eager ) {
46+ if ( options ?. alwaysRedirect ) {
4747 if (
4848 ( c . req . method === 'GET' || c . req . method === 'HEAD' ) &&
4949 c . req . path !== '/' &&
@@ -59,7 +59,7 @@ export const trimTrailingSlash = (options?: TrimTrailingSlashOptions): Middlewar
5959 await next ( )
6060
6161 if (
62- ! options ?. eager &&
62+ ! options ?. alwaysRedirect &&
6363 c . res . status === 404 &&
6464 ( c . req . method === 'GET' || c . req . method === 'HEAD' ) &&
6565 c . req . path !== '/' &&
@@ -81,7 +81,7 @@ type AppendTrailingSlashOptions = {
8181 * If `false` (default), it will only redirect when the route is not found (404).
8282 * @default false
8383 */
84- eager ?: boolean
84+ alwaysRedirect ?: boolean
8585}
8686
8787/**
@@ -102,16 +102,16 @@ type AppendTrailingSlashOptions = {
102102 *
103103 * @example
104104 * ```ts
105- * // With eager option for wildcard routes
105+ * // With alwaysRedirect option for wildcard routes
106106 * const app = new Hono()
107107 *
108- * app.use(appendTrailingSlash({ eager : true }))
108+ * app.use(appendTrailingSlash({ alwaysRedirect : true }))
109109 * app.get('/my-path/*', (c) => c.text('Wildcard route'))
110110 * ```
111111 */
112112export const appendTrailingSlash = ( options ?: AppendTrailingSlashOptions ) : MiddlewareHandler => {
113113 return async function appendTrailingSlash ( c , next ) {
114- if ( options ?. eager ) {
114+ if ( options ?. alwaysRedirect ) {
115115 if ( ( c . req . method === 'GET' || c . req . method === 'HEAD' ) && c . req . path . at ( - 1 ) !== '/' ) {
116116 const url = new URL ( c . req . url )
117117 url . pathname += '/'
@@ -123,7 +123,7 @@ export const appendTrailingSlash = (options?: AppendTrailingSlashOptions): Middl
123123 await next ( )
124124
125125 if (
126- ! options ?. eager &&
126+ ! options ?. alwaysRedirect &&
127127 c . res . status === 404 &&
128128 ( c . req . method === 'GET' || c . req . method === 'HEAD' ) &&
129129 c . req . path . at ( - 1 ) !== '/'
0 commit comments