Fix #12. Should work now, just need to test with the various models

This commit is contained in:
Diego Ripley
2026-02-09 07:43:56 -05:00
parent 2ec99f06fd
commit f0dcf62c21
4 changed files with 858 additions and 1 deletions
+13
View File
@@ -2,6 +2,19 @@ import render from 'render2'
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url)
// Redirect to add trailing slash for paths that:
// 1. Don't already have a trailing slash
// 2. Aren't the root path
// 3. Don't have a file extension
if (url.pathname !== '/' &&
!url.pathname.endsWith('/') &&
!url.pathname.match(/\.[^/]+$/)) {
return Response.redirect(url.origin + url.pathname + '/' + url.search, 301)
}
// Let render2 handle the request
return render.fetch(request, env, ctx)
}
}