[READ-ONLY] a fast, modern browser for the npm registry

fix: configure general rule for trailing slash (#649)

authored by

Alex Savelyev and committed by
GitHub
4dd98d5f 4bf73171

+24
+23
app/middleware/trailing-slash.global.ts
··· 1 + /** 2 + * Removes trailing slashes from URLs. 3 + * 4 + * This middleware only runs in development to maintain consistent behavior. 5 + * In production, Vercel handles this redirect via vercel.json. 6 + * 7 + * - /package/vue/ → /package/vue 8 + * - /docs/getting-started/?query=value → /docs/getting-started?query=value 9 + */ 10 + export default defineNuxtRouteMiddleware(to => { 11 + if (!import.meta.dev) return 12 + 13 + if (to.path !== '/' && to.path.endsWith('/')) { 14 + return navigateTo( 15 + { 16 + path: to.path.slice(0, -1), 17 + query: to.query, 18 + hash: to.hash, 19 + }, 20 + { replace: true }, 21 + ) 22 + } 23 + })
+1
vercel.json
··· 1 1 { 2 2 "$schema": "https://openapi.vercel.sh/vercel.json", 3 + "trailingSlash": false, 3 4 "redirects": [ 4 5 { 5 6 "source": "/",