Skip to content

Commit 3cc2025

Browse files
committed
chore: update comment
1 parent ddb61e9 commit 3cc2025

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

server/middleware/canonical-redirects.global.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
/**
2-
* Redirect legacy URLs to canonical paths (client-side only)
2+
* Redirect legacy/shorthand URLs to canonical paths.
33
*
4+
* Handled here:
5+
* - /@org/pkg or /pkg → /package/@org/pkg or /package/pkg
6+
* - /@org/pkg/v/ver or /pkg@ver → /package/@org/pkg/v/ver or /package/pkg/v/ver
7+
* - /@org → /org/org
8+
*
9+
* Handled via route aliases (not here):
410
* - /package/code/* → /package-code/*
5-
* - /code/* → /package-code/*
11+
* - /code/* → /package-code/*
612
* - /package/docs/* → /package-docs/*
7-
* - /docs/* → /package-docs/*
8-
* - /org/* → /@*
9-
* - /* → /package/* (Unless it's an existing page)
13+
* - /docs/* → /package-docs/*
1014
*/
1115
const pages = [
1216
'/about',
@@ -49,7 +53,7 @@ export default defineEventHandler(async event => {
4953
return sendRedirect(event, `/package/${args}/v/${pkgVersionMatch.groups.version}`)
5054
}
5155

52-
// /org/* → /@*
56+
// /@org → /org/org
5357
const orgMatch = path.match(/^\/@(?<org>[^/]+)$/)
5458
if (orgMatch?.groups) {
5559
return sendRedirect(event, `/org/${orgMatch.groups.org}`)

0 commit comments

Comments
 (0)