Skip to content

Commit 4125318

Browse files
committed
fix(docs): redirect any-case error-code URLs to canonical uppercase
Error reference pages are served at /errors/DFxxxx from the content filenames, so lowercase deep links like /errors/df8111 404. Add a server middleware that 308-redirects any-case DFxxxx error-code paths to their canonical uppercase URL, mirroring the existing trailing-slash middleware.
1 parent 26cf0c5 commit 4125318

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Error reference pages live at `/errors/DFxxxx` (uppercase, derived from the
3+
* content filenames). Accept any-case deep links like `/errors/df8111` and
4+
* redirect them to the canonical uppercase URL so a single URL is indexed.
5+
*/
6+
export default defineEventHandler((event) => {
7+
const match = /^\/errors\/(df\d{4})(?=\/|$|\?)/i.exec(event.path)
8+
if (!match)
9+
return
10+
const canonical = match[1].toUpperCase()
11+
if (match[1] === canonical)
12+
return // already canonical, let it through
13+
return sendRedirect(event, event.path.replace(match[1], canonical), 308)
14+
})

0 commit comments

Comments
 (0)