mirror of
https://github.com/dataforcanada/d4c-service-main-site.git
synced 2026-06-13 22:10:51 +02:00
Fix #12. Should work now, just need to test with the various models
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user