Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/middleware/builtin/trailing-slash.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ app.get('/my-path/*', (c) => c.text('Wildcard route'))

This option is available for both `trimTrailingSlash` and `appendTrailingSlash`.

### <Badge type="info" text="optional" /> skip: `(path: string) => boolean`

A function that determines whether the redirect should be skipped based on the request path. If the function returns `true`, the redirect will be skipped. This is useful when you want to exclude certain paths, such as those with file extensions, from being redirected.

```ts
app.use(
appendTrailingSlash({
skip: (path) => /\.\w+$/.test(path),
})
)
```

This option is available for both `trimTrailingSlash` and `appendTrailingSlash`.

## Note

It will be enabled when the request method is `GET` and the response status is `404`.
Loading