https://github.com/ascorbic/slash-edge
Banish or add trailing slashes with a Netlify edge function
https://github.com/ascorbic/slash-edge
Last synced: 4 months ago
JSON representation
Banish or add trailing slashes with a Netlify edge function
- Host: GitHub
- URL: https://github.com/ascorbic/slash-edge
- Owner: ascorbic
- Created: 2022-06-17T08:42:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-08T11:41:06.000Z (about 2 years ago)
- Last Synced: 2025-04-14T14:21:38.716Z (10 months ago)
- Language: HTML
- Homepage: https://trailing-slash-edge.netlify.app/
- Size: 35.2 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Strip or add trailing slash
Banish or enforce trailing slashes with Netlify edge functions. [Demo](https://trailing-slash-edge.netlify.app/)
## Usage
You can either manually copy the function, or import it from a URL.
### Manual
Copy the appropriate function from [`/lib/`](https://github.com/ascorbic/slash-edge/tree/main/lib) to your site's `/netlify/edge-functions/` directory.
### Import from URL
Create a handler your site's `/netlify/edge-functions/` directory and export the function from deno.land/x:
```typescript
// /netlify/edge-functions/strip-slash.ts
export { stripSlash as default } from 'https://deno.land/x/slash_handler/mod.ts'
```
After creating the function, you then need to add a declaration to your site's `netlify.toml`:
```toml
[[edge_functions]]
function = "strip-slash" # or "add-slash"
path = "/*"
```
Licence: MIT